|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Cooperative cancellation source paired with CancellationToken. More...
#include <thread_pool.H>
Public Member Functions | |
| CancellationSource ()=default | |
| Default constructor. | |
| CancellationToken | token () const noexcept |
| Return a token observing this source. | |
| void | request_cancel () noexcept |
| Request cancellation for all derived tokens. | |
| void | cancel () noexcept |
| Synonym for request_cancel(). | |
| bool | stop_requested () const noexcept |
| Return true if cancellation has already been requested. | |
| void | reset () |
| Reset the source so future tokens observe a fresh state. | |
Private Attributes | |
| std::shared_ptr< cancellation_detail::Exact_State > | state_ |
Cooperative cancellation source paired with CancellationToken.
Copies of a source share its state. Several threads may call request_cancel(), stop_requested() and token() on the same source at the same time, but reset() and assignment change the source, so they must not run at the same time as another use of it.
Definition at line 495 of file thread_pool.H.
|
default |
Default constructor.
|
inlinenoexcept |
Synonym for request_cancel().
Definition at line 525 of file thread_pool.H.
References request_cancel().
|
inlinenoexcept |
Request cancellation for all derived tokens.
It notifies the condition variables registered with its tokens. For a registration made with a mutex, it first takes and releases that mutex, so treat this call as taking each of those mutexes, one at a time (see CancellationToken::notify_on_cancel(cv, mutex)).
Definition at line 517 of file thread_pool.H.
References state_.
Referenced by cancel().
|
inline |
Reset the source so future tokens observe a fresh state.
Definition at line 534 of file thread_pool.H.
References state_.
|
inlinenoexcept |
Return true if cancellation has already been requested.
Definition at line 528 of file thread_pool.H.
References state_.
|
inlinenoexcept |
Return a token observing this source.
Definition at line 505 of file thread_pool.H.
References state_.
Referenced by example_structured_concurrency().
|
private |
Definition at line 497 of file thread_pool.H.
Referenced by request_cancel(), reset(), stop_requested(), and token().