|
FEAT 3
Finite Element Analysis Toolbox
|
Thread fence synchronization utility class. More...
#include <thread.hpp>
Public Member Functions | |
| ThreadFence () | |
| constructor More... | |
| ThreadFence (const ThreadFence &)=delete | |
| delete copy-constructor | |
| void | close () |
| Close the fence and reset internal state. More... | |
| void | open (bool okay=true) |
| Open the fence and notify all waiting threads. More... | |
| ThreadFence & | operator= (const ThreadFence &)=delete |
| delete copy-assignment operator | |
| bool | wait () |
| Wait for the fence to be opened. More... | |
Private Attributes | |
| std::condition_variable | _cvar |
| the internal condition variable More... | |
| std::mutex | _mtx |
| the internal mutex More... | |
| bool | _okay |
| additional state variable More... | |
| bool | _open |
| current state of the fence: open or closed More... | |
Thread fence synchronization utility class.
This class implements a "fence" for manual thread synchronization, which is characterized by the following properties:
In addition to the above properties, this class also stores an additional internal boolean state variable, which is specified by the open() function and is returned by the wait() function.
Definition at line 35 of file thread.hpp.
|
inlineexplicit |
constructor
Definition at line 49 of file thread.hpp.
|
inline |
Close the fence and reset internal state.
Definition at line 97 of file thread.hpp.
|
inline |
|
inline |
Wait for the fence to be opened.
This function causes the calling thread to wait for the fence to be opened by another thread. If the fence is already open at the time when this function is called, then this function returns immediately without blocking the calling thread.
open() function. Definition at line 68 of file thread.hpp.
|
private |
the internal condition variable
Definition at line 41 of file thread.hpp.
|
private |
the internal mutex
Definition at line 39 of file thread.hpp.
|
private |
additional state variable
Definition at line 45 of file thread.hpp.
|
private |
current state of the fence: open or closed
Definition at line 43 of file thread.hpp.