OGS
ThreadException.h
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2
// SPDX-License-Identifier: BSD-3-Clause
3
4
#pragma once
5
6
#include <exception>
7
#include <mutex>
8
16
class
ThreadException
17
{
18
public
:
19
void
capture
()
20
{
21
std::unique_lock<std::mutex> guard{
lock_
};
22
exception_
= std::current_exception();
23
}
24
25
void
rethrow
()
26
{
27
if
(
exception_
)
28
{
29
std::rethrow_exception(
exception_
);
30
}
31
}
32
33
explicit
operator
bool() const noexcept {
return
exception_
!=
nullptr
; }
34
35
private
:
36
std::exception_ptr
exception_
=
nullptr
;
37
std::mutex
lock_
;
38
};
ThreadException
Definition
ThreadException.h:17
ThreadException::rethrow
void rethrow()
Definition
ThreadException.h:25
ThreadException::exception_
std::exception_ptr exception_
Definition
ThreadException.h:36
ThreadException::lock_
std::mutex lock_
Definition
ThreadException.h:37
ThreadException::capture
void capture()
Definition
ThreadException.h:19
BaseLib
ThreadException.h
Generated by
1.14.0