Asio Extensions
Additional functionality built on top of (Boost.)Asio
asioext::cancellation_token_source Class Reference

Manager for cancellation_tokens. More...

#include <asioext/cancellation_token.hpp>

Public Member Functions

 cancellation_token_source ()
 Construct a cancellation_token_source. More...
 
 cancellation_token_source (cancellation_token_source &&other) noexcept
 Move-construct a cancellation_token_source. More...
 
cancellation_token_sourceoperator= (cancellation_token_source &&other) noexcept
 Move-assign a cancellation_token_source. More...
 
void cancel ()
 Cancel all currently issued cancellation_tokens. More...
 
void destroy () noexcept
 Cancel all tokens, present and future. More...
 
void reset ()
 Reset a destroyed token source. More...
 

Friends

class cancellation_token
 

Detailed Description

Manager for cancellation_tokens.

This class provides functionality to create and cancel cancellation_tokens.

Constructor & Destructor Documentation

◆ cancellation_token_source() [1/2]

asioext::cancellation_token_source::cancellation_token_source ( )

◆ cancellation_token_source() [2/2]

asioext::cancellation_token_source::cancellation_token_source ( cancellation_token_source &&  other)
noexcept

Move-construct a cancellation_token_source.

This constructor moves the token source.

Parameters
otherThe other cancellation_token_source object from which the move will occur.
Note
Following the move, the moved-from object is in the same state as if destroy() had been called on it.

Member Function Documentation

◆ cancel()

void asioext::cancellation_token_source::cancel ( )

Cancel all currently issued cancellation_tokens.

This function cancels all tokens that have been issued until this call.

Tokens issued after a call to cancel() are unaffected.

◆ destroy()

void asioext::cancellation_token_source::destroy ( )
noexcept

Cancel all tokens, present and future.

This function cancels all currently issued tokens, as well as tokens issued after this call.

All new tokens created from this source will start in the cancelled state.

See also
reset()

◆ operator=()

cancellation_token_source& asioext::cancellation_token_source::operator= ( cancellation_token_source &&  other)
noexcept

Move-assign a cancellation_token_source.

This assignment operator moves the token source.

Parameters
otherThe other cancellation_token_source object from which the move will occur.
Note
Following the move, the moved-from object is in the same state as if destroy() had been called on it.

◆ reset()

void asioext::cancellation_token_source::reset ( )

Reset a destroyed token source.

This function resets a destroyed token source, so that it can be used to issue and cancel tokens again.

After a call to this function, the object's state is as if just constructed.

See also
destroy()

Friends And Related Function Documentation

◆ cancellation_token

friend class cancellation_token
friend