ThreadSchedule 1.0.0
Modern C++ thread management library
Loading...
Searching...
No Matches
threadschedule::ScheduledTaskHandle Class Reference

Copyable handle for a cancellable scheduled task. More...

#include <scheduled_pool.hpp>

Public Member Functions

 ScheduledTaskHandle (uint64_t id)
void cancel ()
auto is_cancelled () const noexcept -> bool
auto id () const noexcept -> uint64_t

Friends

template<typename>
class ScheduledThreadPoolT

Detailed Description

Copyable handle for a cancellable scheduled task.

Copyable (the cancel flag is shared via std::shared_ptr<std::atomic<bool>>). Both cancel() and is_cancelled() are thread-safe (atomic store / load with release / acquire ordering).

Cancellation is cooperative: the scheduler checks the flag before dispatching the task to the worker pool, but a task that is already executing will not be interrupted.

Definition at line 28 of file scheduled_pool.hpp.

Constructor & Destructor Documentation

◆ ScheduledTaskHandle()

threadschedule::ScheduledTaskHandle::ScheduledTaskHandle ( uint64_t id)
inlineexplicit

Definition at line 31 of file scheduled_pool.hpp.

Member Function Documentation

◆ cancel()

void threadschedule::ScheduledTaskHandle::cancel ( )
inline

Definition at line 35 of file scheduled_pool.hpp.

◆ id()

auto threadschedule::ScheduledTaskHandle::id ( ) const -> uint64_t
inlinenodiscardnoexcept

Definition at line 45 of file scheduled_pool.hpp.

◆ is_cancelled()

auto threadschedule::ScheduledTaskHandle::is_cancelled ( ) const -> bool
inlinenodiscardnoexcept

Definition at line 40 of file scheduled_pool.hpp.

◆ ScheduledThreadPoolT

template<typename>
friend class ScheduledThreadPoolT
friend

Definition at line 55 of file scheduled_pool.hpp.


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