.. index:: pair: class; EE::CancellationToken .. _doxid-class_e_e_1_1_cancellation_token: class EE::CancellationToken =========================== .. toctree:: :hidden: Overview ~~~~~~~~ Cheap, copyable observer of a cancellation request. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include class CancellationToken { public: // methods bool :ref:`isCancellationRequested`() const; :ref:`CancellationRegistration` :ref:`onCancel`(:ref:`detail::CancellationState::Callback` callback) const; bool :target:`operator==`(const CancellationToken& other) const; }; .. _details-class_e_e_1_1_cancellation_token: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Cheap, copyable observer of a cancellation request. A default-constructed token can never be cancelled. Tokens keep the shared state alive independently of their :ref:`CancellationSource `. Methods ------- .. index:: pair: function; isCancellationRequested .. _doxid-class_e_e_1_1_cancellation_token_1ac0df1fe14617e579521a93ab7268f507: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool isCancellationRequested() const .. rubric:: Returns: True once the owning source requested cancellation. .. index:: pair: function; onCancel .. _doxid-class_e_e_1_1_cancellation_token_1aee95ec3b9bb9da5661243bdc776cb8c2: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`CancellationRegistration` onCancel(:ref:`detail::CancellationState::Callback` callback) const Registers a callback that runs synchronously on the thread calling cancel(). If cancellation already happened, the callback runs immediately on the calling thread and the returned registration is empty.