class EE::CancellationToken

Overview

Cheap, copyable observer of a cancellation request. More…

#include <cancellationtoken.hpp>

class CancellationToken {
public:
    // methods

    bool isCancellationRequested() const;
    CancellationRegistration onCancel(detail::CancellationState::Callback callback) const;
    bool operator==(const CancellationToken& other) const;
};

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 CancellationSource.

Methods

bool isCancellationRequested() const

Returns:

True once the owning source requested cancellation.

CancellationRegistration onCancel(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.