Donner SVG main
0.8.0 ยท 766e862a0.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
TaskScope.h File Reference

Synchronous scopes, joined on the thread that created them, and Join. More...

#include <atomic>
#include <cstdint>
#include <thread>
#include <utility>
#include "donner/base/tasks/Parker.h"
#include "donner/base/tasks/ScopeStop.h"
#include "donner/base/tasks/TaskScheduler.h"
Include dependency graph for TaskScope.h:
This graph shows which files directly or indirectly include this file:

Classes

class  donner::tasks::TaskScope
 Counts the tasks spawned into it, and is joined, by wait or the destructor, on the thread that created it. More...

Namespaces

namespace  donner
 Top-level Donner namespace, which is split into different sub-namespaces such as donner::svg and donner::css.

Functions

template<typename A, typename B>
void donner::tasks::Join (TaskScheduler &scheduler, A &&a, B &&b)
 Runs a and b, possibly in parallel, and returns when both have finished.

Detailed Description

Synchronous scopes, joined on the thread that created them, and Join.

Function Documentation

◆ Join()

template<typename A, typename B>
void donner::tasks::Join ( TaskScheduler & scheduler,
A && a,
B && b )

Runs a and b, possibly in parallel, and returns when both have finished.

On a worker, b is pushed to the worker's deque and a runs on the calling thread; the wait then takes b back and runs it if no other worker stole it, and otherwise waits for it as a TaskScope's creator does. On an adopted thread it also takes back its local second branch. An ordinary non-worker spawns b to the scheduler's global queue, a runs on the calling thread, and the call then waits for b as a TaskScope does; it cannot take b back. With zero workers, a runs and then b, both on the calling thread.

Parameters
schedulerThe scheduler that runs b.
aRuns on the calling thread.
bRuns on a worker, or inline when the scheduler cannot queue it.