cxxmcp 1.1.6
C++ MCP SDK
Loading...
Searching...
No Matches
mcp::CancellationToken Class Reference

Copyable token observed by cancellation-aware SDK operations. More...

#include <cancellation.hpp>

Public Member Functions

 CancellationToken ()
 Constructs a detached token (same as none()).
 
bool cancelled () const noexcept
 Returns true after the associated source has requested cancellation.
 
bool cancellable () const noexcept
 Returns true when this token is attached to a cancellation source.
 
bool wait_for_cancel () const
 Block until cancellation is requested.
 
bool wait_for_cancel (std::chrono::milliseconds timeout) const
 Block until cancellation is requested or timeout expires.
 
bool wait_for_cancel (std::chrono::steady_clock::time_point deadline) const
 Block until cancellation is requested or deadline is reached.
 

Static Public Member Functions

static CancellationToken none ()
 Constructs a detached token that is never cancelled.
 

Friends

class CancellationSource
 
detail::CancellationRegistration detail::register_cancellation_callback (CancellationToken token, std::function< void()> callback)
 

Detailed Description

Copyable token observed by cancellation-aware SDK operations.

Member Function Documentation

◆ none()

static CancellationToken mcp::CancellationToken::none ( )
inlinestatic

Constructs a detached token that is never cancelled.

Use this when no cancellation source is needed. The token's cancelled() always returns false and wait_for_cancel() returns false immediately.

◆ wait_for_cancel() [1/3]

bool mcp::CancellationToken::wait_for_cancel ( ) const
inline

Block until cancellation is requested.

Returns true when cancelled. CV-based, no polling.

◆ wait_for_cancel() [2/3]

bool mcp::CancellationToken::wait_for_cancel ( std::chrono::milliseconds  timeout) const
inline

Block until cancellation is requested or timeout expires.

Returns true if cancelled, false if timeout.

◆ wait_for_cancel() [3/3]

bool mcp::CancellationToken::wait_for_cancel ( std::chrono::steady_clock::time_point  deadline) const
inline

Block until cancellation is requested or deadline is reached.

Returns true if cancelled, false if deadline passed.


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