template<typename T>
class threadschedule::WorkStealingDeque< T >
Work-stealing deque for per-thread task queues in a thread pool.
Implements a double-ended queue where the owning worker thread pushes and pops tasks from the top, while other ("thief") threads steal tasks from the bottom. This asymmetry reduces contention under typical workloads because the owner operates on one end and thieves on the other.
- Thread safety
- All public operations are serialized by an internal mutex, so the deque is safe to use concurrently from any number of threads. The atomic counters (top_ / bottom_) exist for a fast, lock-free size() / empty() snapshot but do not make push/pop/steal lock-free; the mutex is always acquired.
- Capacity
- The deque has a fixed capacity set at construction (default
DEFAULT_CAPACITY = 1024). push() returns false when the deque is full; it never reallocates. Choose a capacity large enough for your expected burst size or use an overflow queue externally (as HighPerformancePool does).
- Memory layout
- Each stored item is wrapped in an
AlignedItem that is aligned to CACHE_LINE_SIZE (64 bytes) to prevent false sharing between adjacent elements when multiple threads access neighboring slots.
- Copyability / movability
- Not copyable and not movable (contains a std::mutex).
- Template Parameters
-
| T | The task type. Must be move-constructible. |
Definition at line 50 of file thread_pool.hpp.