C++ Rest SDK
The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
pplx::cancellation_token Class Reference

The cancellation_token class represents the ability to determine whether some operation has been requested to cancel. A given token can be associated with a task_group, structured_task_group, or task to provide implicit cancellation. It can also be polled for cancellation or have a callback registered for if and when the associated cancellation_token_source is canceled. More...

#include <pplxcancellation_token.h>

Public Types

typedef details::_CancellationTokenState_ImplType
 

Public Member Functions

 cancellation_token (const cancellation_token &_Src)
 
 cancellation_token (cancellation_token &&_Src)
 
cancellation_tokenoperator= (const cancellation_token &_Src)
 
cancellation_tokenoperator= (cancellation_token &&_Src)
 
bool operator== (const cancellation_token &_Src) const
 
bool operator!= (const cancellation_token &_Src) const
 
bool is_cancelable () const
 Returns an indication of whether this token can be canceled or not. More...
 
bool is_canceled () const
 Returns true if the token has been canceled. More...
 
template<typename _Function >
::pplx::cancellation_token_registration register_callback (const _Function &_Func) const
 Registers a callback function with the token. If and when the token is canceled, the callback will be made. Note that if the token is already canceled at the point where this method is called, the callback will be made immediately and synchronously. More...
 
void deregister_callback (const cancellation_token_registration &_Registration) const
 Removes a callback previously registered via the register method based on the cancellation_token_registration object returned at the time of registration. More...
 
_ImplType _GetImpl () const
 
_ImplType _GetImplValue () const
 

Static Public Member Functions

static cancellation_token none ()
 Returns a cancellation token which can never be subject to cancellation. More...
 
static cancellation_token _FromImpl (_ImplType _Impl)
 

Friends

class cancellation_token_source
 

Detailed Description

The cancellation_token class represents the ability to determine whether some operation has been requested to cancel. A given token can be associated with a task_group, structured_task_group, or task to provide implicit cancellation. It can also be polled for cancellation or have a callback registered for if and when the associated cancellation_token_source is canceled.

Member Function Documentation

void pplx::cancellation_token::deregister_callback ( const cancellation_token_registration _Registration) const
inline

Removes a callback previously registered via the register method based on the cancellation_token_registration object returned at the time of registration.

Parameters
_RegistrationThe cancellation_token_registration object corresponding to the callback to be deregistered. This token must have been previously returned from a call to the register method.
bool pplx::cancellation_token::is_cancelable ( ) const
inline

Returns an indication of whether this token can be canceled or not.

Returns
An indication of whether this token can be canceled or not.
bool pplx::cancellation_token::is_canceled ( ) const
inline

Returns true if the token has been canceled.

Returns
The value true if the token has been canceled; otherwise, the value false.
static cancellation_token pplx::cancellation_token::none ( )
inlinestatic

Returns a cancellation token which can never be subject to cancellation.

Returns
A cancellation token that cannot be canceled.
template<typename _Function >
::pplx::cancellation_token_registration pplx::cancellation_token::register_callback ( const _Function &  _Func) const
inline

Registers a callback function with the token. If and when the token is canceled, the callback will be made. Note that if the token is already canceled at the point where this method is called, the callback will be made immediately and synchronously.

Template Parameters
_FunctionThe type of the function object that will be called back when this cancellation_token is canceled.
Parameters
_FuncThe function object that will be called back when this cancellation_token is canceled.
Returns
A cancellation_token_registration object which can be utilized in the deregister method to deregister a previously registered callback and prevent it from being made. The method will throw an invalid_operation exception if it is called on a cancellation_token object that was created using the cancellation_token::none method.

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