Class TaskQueue

Class Documentation

class quickpool::sched::TaskQueue

A multi-producer, multi-consumer queue; pops are lock free.

Public Functions

inline TaskQueue(size_t capacity = 256)
Parameters

capacity – must be a power of two.

inline ~TaskQueue() noexcept
TaskQueue(TaskQueue const &other) = delete
TaskQueue &operator=(TaskQueue const &other) = delete
inline bool empty() const

checks if queue is empty.

inline void push(Task &&task)

pushes a task to the bottom of the queue; returns false if queue is currently locked; enlarges the queue if full.

inline bool try_pop(Task &task)

pops a task from the top of the queue; returns false if lost race.

inline void wait()

waits for tasks or stop signal.

inline void stop()

stops the queue and wakes up all workers waiting for jobs.

inline void wake_up()