Share via


cancellation_token_source Class

 

The cancellation_token_source class represents the ability to cancel some cancelable operation.

Syntax

class cancellation_token_source;

Members

Public Constructors

Name Description
cancellation_token_source::cancellation_token_source Constructor Overloaded. Constructs a new cancellation_token_source. The source can be used to flag cancellation of some cancelable operation.
cancellation_token_source::~cancellation_token_source Destructor

Public Methods

Name Description
cancellation_token_source::cancel Method Cancels the token. Any task_group, structured_task_group, or task which utilizes the token will be canceled upon this call and throw an exception at the next interruption point.
cancellation_token_source::create_linked_source Method Overloaded. Creates a cancellation_token_source which is canceled when the provided token is canceled.
cancellation_token_source::get_token Method Returns a cancellation token associated with this source. The returned token can be polled for cancellation or provide a callback if and when cancellation occurs.

Public Operators

Name Description
cancellation_token_source::operator!= Operator
cancellation_token_source::operator= Operator
cancellation_token_source::operator== Operator

Inheritance Hierarchy

cancellation_token_source

Requirements

Header: pplcancellation_token.h

Namespace: concurrency

cancellation_token_source::~cancellation_token_source Destructor

~cancellation_token_source();

cancellation_token_source::cancel Method

Cancels the token. Any task_group, structured_task_group, or task which utilizes the token will be canceled upon this call and throw an exception at the next interruption point.

void cancel() const;

cancellation_token_source::cancellation_token_source Constructor

Constructs a new cancellation_token_source. The source can be used to flag cancellation of some cancelable operation.

cancellation_token_source();

cancellation_token_source(const cancellation_token_source& _Src);

cancellation_token_source(cancellation_token_source&& _Src);

Parameters

_Src

cancellation_token_source::create_linked_source Method

Creates a cancellation_token_source which is canceled when the provided token is canceled.

static cancellation_token_source create_linked_source(
    cancellation_token& _Src);

template<typename _Iter>
static cancellation_token_source create_linked_source(_Iter _Begin, _Iter _End);

Parameters

_Iter
_Src
A token whose cancellation will cause cancellation of the returned token source. Note that the returned token source can also be canceled independently of the source contained in this parameter.

_Begin
The STL iterator corresponding to the beginning of the range of tokens to listen for cancellation of.

_End
The STL iterator corresponding to the ending of the range of tokens to listen for cancellation of.

Return Value

A cancellation_token_source which is canceled when the token provided by the _Src parameter is canceled.

cancellation_token_source::get_token Method

Returns a cancellation token associated with this source. The returned token can be polled for cancellation or provide a callback if and when cancellation occurs.

cancellation_token get_token() const;

Return Value

A cancellation token associated with this source.

cancellation_token_source::operator!= Operator

bool operator!= (const cancellation_token_source& _Src) const;

Parameters

_Src

Return Value

cancellation_token_source::operator= Operator

cancellation_token_source& operator= (const cancellation_token_source& _Src);

cancellation_token_source& operator= (cancellation_token_source&& _Src);

Parameters

_Src

Return Value

cancellation_token_source::operator== Operator

bool operator== (const cancellation_token_source& _Src) const;

Parameters

_Src

Return Value

See Also

concurrency Namespace