userver: engine::TaskCancellationToken Class Reference
No Matches
engine::TaskCancellationToken Class Referencefinal

#include <userver/engine/task/cancel.hpp>

Detailed Description

Cancellation token to given task object.

Unlike Task, TaskCancellationToken object doesn't wait for task finish in its destructor. It is allowed to outlive the task object it was created from. However, as long as there is any cancellation token associated with given task, some internal structures of a task will not be freed.

General rule: whenever possible, prefer using engine::Task object instead.

Definition at line 99 of file cancel.hpp.

Public Member Functions

 TaskCancellationToken () noexcept
 Creates an invalid TaskCancellationToken.
 TaskCancellationToken (Task &task)
 TaskCancellationToken (const TaskCancellationToken &) noexcept
 TaskCancellationToken (TaskCancellationToken &&) noexcept
TaskCancellationTokenoperator= (const TaskCancellationToken &) noexcept
TaskCancellationTokenoperator= (TaskCancellationToken &&) noexcept
void RequestCancel ()
bool IsValid () const noexcept
 True if this token is associated with a task.

Constructor & Destructor Documentation

◆ TaskCancellationToken()

engine::TaskCancellationToken::TaskCancellationToken ( Task & task)

Creates a TaskCancellationToken associated with a task. The task must be valid.

Member Function Documentation

◆ RequestCancel()

void engine::TaskCancellationToken::RequestCancel ( )
See also
engine::Task::RequestCancel This method should not be called on invalid TaskCancellationToken

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