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

A one-word parker: a thread sleeps on it until another thread changes it. More...

#include <atomic>
#include <cstdint>
#include <type_traits>
#include "donner/base/Utils.h"
Include dependency graph for Parker.h:
This graph shows which files directly or indirectly include this file:

Classes

struct  donner::tasks::PlatformParkerHooks< WordT >
 The platform policy of a Parker over WordT: std::atomic::wait and std::atomic::notify_one, and a hook at each step of Parker::parkUntil that compiles to nothing. More...
class  donner::tasks::Parker< Hooks >
 A parker: one atomic word holding a waiting bit and an epoch, that one thread, its sleeper, waits on and any thread changes to wake it. More...

Namespaces

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

Typedefs

using donner::tasks::NativeParkerWord = std::int32_t
 The parker word's type: exactly the type the standard library's std::atomic::wait waits on natively, so a parker never goes through the library's shared contention table, whose buckets unrelated addresses share.
using donner::tasks::NoParkerHooks = PlatformParkerHooks<NativeParkerWord>
 The production policy: the platform wait on NativeParkerWord.

Detailed Description

A one-word parker: a thread sleeps on it until another thread changes it.

Typedef Documentation

◆ NativeParkerWord

using donner::tasks::NativeParkerWord = std::int32_t

The parker word's type: exactly the type the standard library's std::atomic::wait waits on natively, so a parker never goes through the library's shared contention table, whose buckets unrelated addresses share.

It is the one place the word type is chosen.

  • libc++ (Linux, Apple): __atomic/atomic_sync.h waits and notifies on the address itself only when the value type is the library's contention type __cxx_contention_t (__atomic/contention_t.h), as decided by __has_native_atomic_wait (__atomic/atomic_waitable_traits.h) or, in the older interface Apple's SDK uses, by the overloads on __cxx_atomic_contention_t. With the ABI version these builds use, that type is int32_t on Linux and int64_t on Apple, and it must match exactly: an unsigned word of the same width, or long on Apple, takes the table.
  • libstdc++ (Linux): bits/atomic_wait.h waits on the futex for every 4-byte scalar (__platform_wait_uses_type), so std::int32_t is native there too.
  • Emscripten's libc++ has no platform wait: its src/atomic.cpp polls with a timed backoff and its notify does nothing, whatever the type. The word stays a signed 32-bit integer there, the width of emscripten_futex_wait, for a direct futex wait.
  • Windows is not built; which types its standard library waits on natively is not verified.