ecor
Loading...
Searching...
No Matches
ecor::inplace_stop_source Struct Reference

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_sourceoperator= (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
 

Detailed Description

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.

Member Function Documentation

◆ get_token()

inplace_stop_token ecor::inplace_stop_source::get_token ( ) const
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.

◆ request_stop()

bool ecor::inplace_stop_source::request_stop ( )
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.

◆ stop_possible()

bool ecor::inplace_stop_source::stop_possible ( ) const
inlinenoexcept

Check if stopping is possible.

For inplace_stop_source, this always returns true since it can always be stopped.

◆ stop_requested()

bool ecor::inplace_stop_source::stop_requested ( ) const
inlinenoexcept

Check if a stop has been requested.

This returns true if request_stop() has been called on this stop source, and false otherwise.


The documentation for this struct was generated from the following file: