STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
Concurrency::cancellation_token_source Class Reference

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

#include <pplcancellation_token.h>

Public Types

typedef ::Concurrency::details::_CancellationTokenState_ImplType
 

Public Member Functions

 cancellation_token_source ()
 Constructs a new cancellation_token_source. The source can be used to flag cancellation of some cancelable operation. More...
 
 cancellation_token_source (const cancellation_token_source &_Src)
 
 cancellation_token_source (cancellation_token_source &&_Src)
 
cancellation_token_sourceoperator= (const cancellation_token_source &_Src)
 
cancellation_token_sourceoperator= (cancellation_token_source &&_Src)
 
bool operator== (const cancellation_token_source &_Src) const
 
bool operator!= (const cancellation_token_source &_Src) const
 
 ~cancellation_token_source ()
 
cancellation_token get_token () const
 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. More...
 
void cancel () const
 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. More...
 
_ImplType _GetImpl () const
 

Static Public Member Functions

static cancellation_token_source create_linked_source (cancellation_token &_Src)
 Creates a cancellation_token_source which is canceled when the provided token is canceled. More...
 
template<typename _Iter >
static cancellation_token_source create_linked_source (_Iter _Begin, _Iter _End)
 Creates a cancellation_token_source which is canceled when one of a series of tokens represented by an STL iterator pair is canceled. More...
 
static cancellation_token_source _FromImpl (_ImplType _Impl)
 

Private Member Functions

void _Clear ()
 
void _Assign (_ImplType _Impl)
 
void _Move (_ImplType &_Impl)
 
 cancellation_token_source (_ImplType _Impl)
 

Private Attributes

_ImplType _M_Impl
 

Detailed Description

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

Member Typedef Documentation

Constructor & Destructor Documentation

Concurrency::cancellation_token_source::cancellation_token_source ( )
inline

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

821  {
822  _M_Impl = new ::Concurrency::details::_CancellationTokenState;
823  }
_ImplType _M_Impl
Definition: pplcancellation_token.h:948
Concurrency::cancellation_token_source::cancellation_token_source ( const cancellation_token_source _Src)
inline
826  {
827  _Assign(_Src._M_Impl);
828  }
void _Assign(_ImplType _Impl)
Definition: pplcancellation_token.h:959
Concurrency::cancellation_token_source::cancellation_token_source ( cancellation_token_source &&  _Src)
inline
831  {
832  _Move(_Src._M_Impl);
833  }
void _Move(_ImplType &_Impl)
Definition: pplcancellation_token.h:968
Concurrency::cancellation_token_source::~cancellation_token_source ( )
inline
866  {
867  if (_M_Impl != NULL)
868  {
869  _M_Impl->_Release();
870  }
871  }
#define NULL
Definition: vcruntime.h:236
_ImplType _M_Impl
Definition: pplcancellation_token.h:948
long _Release()
Definition: pplcancellation_token.h:73
Concurrency::cancellation_token_source::cancellation_token_source ( _ImplType  _Impl)
inlineprivate
974  :
975  _M_Impl(_Impl)
976  {
978  {
979  _M_Impl = NULL;
980  }
981 
982  if (_M_Impl != NULL)
983  {
984  _M_Impl->_Reference();
985  }
986  }
#define NULL
Definition: vcruntime.h:236
_ImplType _M_Impl
Definition: pplcancellation_token.h:948
static _CancellationTokenState * _None()
Definition: pplcancellation_token.h:332
long _Reference()
Definition: pplcancellation_token.h:62

Member Function Documentation

void Concurrency::cancellation_token_source::_Assign ( _ImplType  _Impl)
inlineprivate
960  {
961  if (_Impl != NULL)
962  {
963  _Impl->_Reference();
964  }
965  _M_Impl = _Impl;
966  }
#define NULL
Definition: vcruntime.h:236
_ImplType _M_Impl
Definition: pplcancellation_token.h:948
void Concurrency::cancellation_token_source::_Clear ( )
inlineprivate
951  {
952  if (_M_Impl != NULL)
953  {
954  _M_Impl->_Release();
955  }
956  _M_Impl = NULL;
957  }
#define NULL
Definition: vcruntime.h:236
_ImplType _M_Impl
Definition: pplcancellation_token.h:948
long _Release()
Definition: pplcancellation_token.h:73
static cancellation_token_source Concurrency::cancellation_token_source::_FromImpl ( _ImplType  _Impl)
inlinestatic
942  {
943  return cancellation_token_source(_Impl);
944  }
cancellation_token_source()
Constructs a new cancellation_token_source. The source can be used to flag cancellation of some cance...
Definition: pplcancellation_token.h:820
_ImplType Concurrency::cancellation_token_source::_GetImpl ( ) const
inline
937  {
938  return _M_Impl;
939  }
_ImplType _M_Impl
Definition: pplcancellation_token.h:948
void Concurrency::cancellation_token_source::_Move ( _ImplType _Impl)
inlineprivate
969  {
970  _M_Impl = _Impl;
971  _Impl = NULL;
972  }
#define NULL
Definition: vcruntime.h:236
_ImplType _M_Impl
Definition: pplcancellation_token.h:948
void Concurrency::cancellation_token_source::cancel ( ) const
inline

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.

932  {
933  _M_Impl->_Cancel();
934  }
void _Cancel()
Definition: pplcancellation_token.h:367
_ImplType _M_Impl
Definition: pplcancellation_token.h:948
static cancellation_token_source Concurrency::cancellation_token_source::create_linked_source ( cancellation_token _Src)
inlinestatic

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

Parameters
_SrcA 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.
Returns
A cancellation_token_source which is canceled when the token provided by the _Src parameter is canceled.
896  {
897  cancellation_token_source _NewSource;
898  _Src.register_callback( [_NewSource](){ _NewSource.cancel(); } );
899  return _NewSource;
900  }
cancellation_token_source()
Constructs a new cancellation_token_source. The source can be used to flag cancellation of some cance...
Definition: pplcancellation_token.h:820
template<typename _Iter >
static cancellation_token_source Concurrency::cancellation_token_source::create_linked_source ( _Iter  _Begin,
_Iter  _End 
)
inlinestatic

Creates a cancellation_token_source which is canceled when one of a series of tokens represented by an STL iterator pair is canceled.

Parameters
_BeginThe STL iterator corresponding to the beginning of the range of tokens to listen for cancellation of.
_EndThe STL iterator corresponding to the ending of the range of tokens to listen for cancellation of.
Returns
A cancellation_token_source which is canceled when any of the tokens provided by the range described by the STL iterators contained in the _Begin and _End parameters is canceled.
918  {
919  cancellation_token_source _NewSource;
920  for (_Iter _It = _Begin; _It != _End; ++_It)
921  {
922  _It->register_callback( [_NewSource](){ _NewSource.cancel(); } );
923  }
924  return _NewSource;
925  }
cancellation_token_source()
Constructs a new cancellation_token_source. The source can be used to flag cancellation of some cance...
Definition: pplcancellation_token.h:820
cancellation_token Concurrency::cancellation_token_source::get_token ( ) const
inline

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.

Returns
A cancellation token associated with this source.
881  {
882  return cancellation_token(_M_Impl);
883  }
_ImplType _M_Impl
Definition: pplcancellation_token.h:948
bool Concurrency::cancellation_token_source::operator!= ( const cancellation_token_source _Src) const
inline
861  {
862  return !(operator==(_Src));
863  }
bool operator==(const cancellation_token_source &_Src) const
Definition: pplcancellation_token.h:855
cancellation_token_source& Concurrency::cancellation_token_source::operator= ( const cancellation_token_source _Src)
inline
836  {
837  if (this != &_Src)
838  {
839  _Clear();
840  _Assign(_Src._M_Impl);
841  }
842  return *this;
843  }
void _Assign(_ImplType _Impl)
Definition: pplcancellation_token.h:959
void _Clear()
Definition: pplcancellation_token.h:950
cancellation_token_source& Concurrency::cancellation_token_source::operator= ( cancellation_token_source &&  _Src)
inline
846  {
847  if (this != &_Src)
848  {
849  _Clear();
850  _Move(_Src._M_Impl);
851  }
852  return *this;
853  }
void _Clear()
Definition: pplcancellation_token.h:950
void _Move(_ImplType &_Impl)
Definition: pplcancellation_token.h:968
bool Concurrency::cancellation_token_source::operator== ( const cancellation_token_source _Src) const
inline
856  {
857  return _M_Impl == _Src._M_Impl;
858  }
_ImplType _M_Impl
Definition: pplcancellation_token.h:948

Member Data Documentation

_ImplType Concurrency::cancellation_token_source::_M_Impl
private

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