|
Fray Engine
|
Cooperative cancellation shared by every copy of a token. Copies share one state guarded by an internal mutex, so any thread may use any copy. More...
#include <thread_manager.hpp>
Classes | |
| struct | State |
Public Member Functions | |
| bool | stopRequested () const |
| True once requestStop() was called on any copy. Briefly takes the token's mutex. | |
| template<typename Rep, typename Period> | |
| bool | waitFor (const std::chrono::duration< Rep, Period > &duration) const |
| Sleeps for up to duration; returns true as soon as a stop is requested. | |
| void | requestStop () const |
| Requests a stop on all copies and wakes any waitFor() callers. Safe from any thread; idempotent. | |
Private Attributes | |
| std::shared_ptr< State > | _state = std::make_shared<State>() |
Cooperative cancellation shared by every copy of a token. Copies share one state guarded by an internal mutex, so any thread may use any copy.
Definition at line 29 of file thread_manager.hpp.
|
inline |
Requests a stop on all copies and wakes any waitFor() callers. Safe from any thread; idempotent.
Definition at line 64 of file thread_manager.hpp.
|
inline |
True once requestStop() was called on any copy. Briefly takes the token's mutex.
Definition at line 44 of file thread_manager.hpp.
|
inline |
Sleeps for up to duration; returns true as soon as a stop is requested.
| duration | Maximum time to sleep. The token's mutex is released while sleeping. |
Definition at line 56 of file thread_manager.hpp.
State shared by all copies of this token.
Definition at line 40 of file thread_manager.hpp.