#include <FixedWorkStealingQueue.hpp>
A lock-free work-stealing queue of a fixed, pre-allocated size. The queue is designed to act as a circular queue with no upper-bound, instead overwriting older elements when the capacity is reached - this is because the queue is intended to be used with short-running jobs and it's unlikely the queue will reach capacity while active jobs must be dequeued.
Public Member Functions | |
FixedWorkStealingQueue ()=default | |
FixedWorkStealingQueue (const size_t capacity) | |
Initializes the queue with capacity max number of jobs. More... | |
FixedWorkStealingQueue (const FixedWorkStealingQueue &other)=delete | |
FixedWorkStealingQueue & | operator= (const FixedWorkStealingQueue &other)=delete |
FixedWorkStealingQueue (FixedWorkStealingQueue &&other) noexcept | |
FixedWorkStealingQueue & | operator= (FixedWorkStealingQueue &&other) noexcept |
void | push (Job *job) |
bool | pop (Job *&target) |
bool | steal (Job *&target) |
bool | empty () const noexcept |
|
default |
|
inlineexplicit |
Initializes the queue with capacity
max number of jobs.
|
delete |
|
inlinenoexcept |
|
inlinenoexcept |
Checks if the queue is empty - note: not guaranteed to be accurate in concurrent environments for all threads
|
delete |
|
inlinenoexcept |
|
inline |
Pops the next job from the bottom of the queue - must be called from the queues owning thread. Returns false if the pop operation failed.
|
inline |
Pushes a new job onto the bottom of the queue - must be called from the queues owning thread
|
inline |
Steals a job from the top of the queue - can be called from any thread. Returns false if the steal operation failed.