OGS
ThreadException.h
Go to the documentation of this file.
1
10#pragma once
11
12#include <exception>
13#include <mutex>
14
18{
19public:
20 void capture()
21 {
22 std::unique_lock<std::mutex> guard{lock_};
23 exception_ = std::current_exception();
24 }
25
26 void rethrow()
27 {
28 if (exception_)
29 {
30 std::rethrow_exception(exception_);
31 }
32 }
33
34private:
35 std::exception_ptr exception_ = nullptr;
36 std::mutex lock_;
37};
std::exception_ptr exception_