|
ecor
|
In-place stop source, which is a simple implementation of a stoppable source that is designed to be used in-place without dynamic memory allocation. More...
#include <ecor.hpp>
Public Member Functions | |
| inplace_stop_token | get_token () const noexcept |
| Get the stop token associated with this stop source. More... | |
| inplace_stop_source (inplace_stop_source const &)=delete | |
| inplace_stop_source & | operator= (inplace_stop_source const &)=delete |
| bool | request_stop () |
| Request a stop. More... | |
| bool | stop_possible () const noexcept |
| Check if stopping is possible. More... | |
| bool | stop_requested () const noexcept |
| Check if a stop has been requested. More... | |
Friends | |
| template<typename CallbackFn > | |
| struct | inplace_stop_callback |
In-place stop source, which is a simple implementation of a stoppable source that is designed to be used in-place without dynamic memory allocation.
It maintains a list of registered callbacks that are invoked when a stop is requested, allowing for cooperative cancellation of asynchronous operations without the need for dynamic memory allocation.
|
inlinenoexcept |
Get the stop token associated with this stop source.
The returned token can be used to check if a stop has been requested, and to register callbacks that will be invoked when a stop is requested.
|
inline |
Request a stop.
This sets the internal state to indicate that a stop has been requested, and invokes all registered callbacks. Returns true if this call successfully requested a stop, or false if a stop had already been requested.
|
inlinenoexcept |
Check if stopping is possible.
For inplace_stop_source, this always returns true since it can always be stopped.
|
inlinenoexcept |
Check if a stop has been requested.
This returns true if request_stop() has been called on this stop source, and false otherwise.