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

Token to determine if an operation was cancelled. More...

#include <asioext/cancellation_token.hpp>

Public Member Functions

 cancellation_token (const cancellation_token_source &source) noexcept
 
bool cancelled () const noexcept
 Check whether this operation is cancelled. More...
 

Detailed Description

Token to determine if an operation was cancelled.

This class provides the ability to determine if an operation was cancelled. cancellation_token objects can only be created from a cancellation_token_source.

A cancellation_token is not dependent on the lifetime of its cancellation_token_source (i.e. the token can outlive the source).

Constructor & Destructor Documentation

◆ cancellation_token()

asioext::cancellation_token::cancellation_token ( const cancellation_token_source source)
noexcept

Member Function Documentation

◆ cancelled()

bool asioext::cancellation_token::cancelled ( ) const
noexcept

Check whether this operation is cancelled.

This function checks whether this token is cancelled (i.e. whether cancel() has been called after this token was created).

Returns
true if the operation was cancelled, false otherwise.