OGS
ThreadException.h
Go to the documentation of this file.
1
10#pragma once
11
12#include <exception>
13#include <mutex>
14
23{
24public:
25 void capture()
26 {
27 std::unique_lock<std::mutex> guard{lock_};
28 exception_ = std::current_exception();
29 }
30
31 void rethrow()
32 {
33 if (exception_)
34 {
35 std::rethrow_exception(exception_);
36 }
37 }
38
39 explicit operator bool() const noexcept { return exception_ != nullptr; }
40
41private:
42 std::exception_ptr exception_ = nullptr;
43 std::mutex lock_;
44};
std::exception_ptr exception_