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

A fixed-capacity Chase-Lev work-stealing deque. More...

#include <atomic>
#include <cstddef>
#include <cstdint>
#include <memory>
#include <optional>
#include <ostream>
#include <type_traits>
#include "donner/base/Utils.h"
#include "donner/base/tasks/FalseSharing.h"
Include dependency graph for WorkStealingDeque.h:
This graph shows which files directly or indirectly include this file:

Classes

struct  donner::tasks::StealResult< T >
 The result of WorkStealingDeque::steal. More...
struct  donner::tasks::NoDequeHooks
 Test seam with a hook at each claim of a contended entry. More...
class  donner::tasks::WorkStealingDeque< T, kOrdering, Hooks >
 A Chase-Lev work-stealing deque on a fixed ring of slots. More...

Namespaces

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

Enumerations

enum class  donner::tasks::DequeOrdering : std::uint8_t {
  WeakMemory ,
  SequentiallyConsistent
}
 The memory orderings a WorkStealingDeque uses on its indices. More...
enum class  donner::tasks::StealStatus : std::uint8_t {
  Taken ,
  Empty ,
  Lost
}
 How a WorkStealingDeque::steal call ended. More...

Functions

std::ostream & donner::tasks::operator<< (std::ostream &os, DequeOrdering ordering)
 Ostream output operator for DequeOrdering, for test diagnostics.
std::ostream & donner::tasks::operator<< (std::ostream &os, StealStatus status)
 Ostream output operator for StealStatus, for test diagnostics.

Variables

constexpr DequeOrdering donner::tasks::kDefaultDequeOrdering = DequeOrdering::WeakMemory
 The ordering form a WorkStealingDeque uses unless one is named.

Detailed Description

A fixed-capacity Chase-Lev work-stealing deque.

Enumeration Type Documentation

◆ DequeOrdering

enum class donner::tasks::DequeOrdering : std::uint8_t
strong

The memory orderings a WorkStealingDeque uses on its indices.

Enumerator
WeakMemory 

The C11 orderings of Le, Pop, Cohen and Zappa Nardelli, "Correct and Efficient Work-Stealing for Weak Memory Models" (PPoPP 2013), Figure 1: relaxed and release-acquire index accesses, a release fence in push, and sequentially consistent fences in take and steal.

They are proven correct for the Arm and POWER memory models. This is the production form.

SequentiallyConsistent 

Every index access sequentially consistent and no standalone fences.

ThreadSanitizer does not model standalone fences, so this is the form it can check: it sees every ordering the deque relies on as an ordinary atomic. The default in ThreadSanitizer builds.

◆ StealStatus

enum class donner::tasks::StealStatus : std::uint8_t
strong

How a WorkStealingDeque::steal call ended.

Enumerator
Taken 

The thief removed the oldest entry.

Empty 

The deque held no entry when the thief looked.

Lost 

Another thief, or the owner, claimed the entry first; the deque may still hold more.