ThreadSchedule 2.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 33 of file scheduled_pool.hpp.

Constructor & Destructor Documentation

◆ ScheduledTaskHandle()

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

Definition at line 36 of file scheduled_pool.hpp.

References id().

Member Function Documentation

◆ cancel()

void threadschedule::ScheduledTaskHandle::cancel ( )
inline

◆ id()

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

Definition at line 50 of file scheduled_pool.hpp.

Referenced by ScheduledTaskHandle().

◆ is_cancelled()

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

Definition at line 45 of file scheduled_pool.hpp.

◆ ScheduledThreadPoolT

template<typename>
friend class ScheduledThreadPoolT
friend

Definition at line 60 of file scheduled_pool.hpp.

References ScheduledThreadPoolT.

Referenced by ScheduledThreadPoolT.


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