Donner SVG main
0.8.0 ยท 766e862a0.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::tasks::ScopeStop Class Reference

A scope's stop request: cooperative cancellation. More...

#include "donner/base/tasks/ScopeStop.h"

Public Member Functions

 ScopeStop (const ScopeStop &)=delete
 ScopeStop (ScopeStop &&)=delete
ScopeStop & operator= (const ScopeStop &)=delete
ScopeStop & operator= (ScopeStop &&)=delete
void request ()
 Requests the stop. From any thread, any number of times.
bool requested () const
 Whether a stop was requested.

Static Public Member Functions

static bool SkipsQueuedTask (const ScopeStop *stop)
 The check a thread makes before it starts a queued task: true when the task's scope requested a stop, and the task must be destroyed unrun.

Detailed Description

A scope's stop request: cooperative cancellation.

Once requested, a task of the scope that is still queued is not run when a thread takes it: its closure is destroyed unrun, and it still completes its scope's accounting, so the scope's join returns. A task that has started runs to its end and may poll requested to return early. Spawns that run inline, because the scheduler could not queue them, are not queued and are not skipped.

Every access is relaxed: the request is advisory, publishes no data, and a task that misses a request made concurrently with its start simply runs.

A scope type embeds one and gives its address to each task record it spawns; the scheduler makes the check, SkipsQueuedTask, wherever it starts a queued task, so every scope type that links its flag gets the same behavior.

Member Function Documentation

◆ SkipsQueuedTask()

bool donner::tasks::ScopeStop::SkipsQueuedTask ( const ScopeStop * stop)
inlinestaticnodiscard

The check a thread makes before it starts a queued task: true when the task's scope requested a stop, and the task must be destroyed unrun.

Parameters
stopThe task's scope's stop request, or null for a task without one.

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