tf::BoundedTaskQueue
taskflow/core/tsq.hpp
typename T
size_t LogSize LogSize TF_DEFAULT_BOUNDED_TASK_QUEUE_LOG_SIZE
int64_t int64_t tf::BoundedTaskQueue< T, LogSize >::BufferSize BufferSize tf::BoundedTaskQueue::BufferSize = int64_t{1} << LogSize
int64_t int64_t tf::BoundedTaskQueue< T, LogSize >::BufferMask BufferMask tf::BoundedTaskQueue::BufferMask = (BufferSize - 1)
std::atomic< int64_t > std::atomic<int64_t> tf::BoundedTaskQueue< T, LogSize >::_top _top tf::BoundedTaskQueue::_top {0}
std::atomic< int64_t > std::atomic<int64_t> tf::BoundedTaskQueue< T, LogSize >::_bottom _bottom tf::BoundedTaskQueue::_bottom {0}
std::atomic< T > std::atomic<T> tf::BoundedTaskQueue< T, LogSize >::_buffer[BufferSize] [BufferSize] _buffer tf::BoundedTaskQueue::_buffer
tf::BoundedTaskQueue< T, LogSize >::BoundedTaskQueue
()=default
BoundedTaskQueue
tf::BoundedTaskQueue::BoundedTaskQueue

constructs the queue with a given capacity

tf::BoundedTaskQueue< T, LogSize >::~BoundedTaskQueue
()=default
~BoundedTaskQueue
tf::BoundedTaskQueue::~BoundedTaskQueue

destructs the queue

bool bool tf::BoundedTaskQueue< T, LogSize >::empty () const noexcept empty tf::BoundedTaskQueue::empty

queries if the queue is empty at the time of this call

size_t size_t tf::BoundedTaskQueue< T, LogSize >::size () const noexcept size tf::BoundedTaskQueue::size

queries the number of items at the time of this call

size_t size_t tf::BoundedTaskQueue< T, LogSize >::capacity () const capacity tf::BoundedTaskQueue::capacity

queries the capacity of the queue

typename O
bool bool tf::BoundedTaskQueue< T, LogSize >::try_push (O &&item) try_push tf::BoundedTaskQueue::try_push O && item

tries to insert an item to the queue

O

data type

item

the item to perfect-forward to the queue

`true` if the insertion succeed or `false` (queue is full)

Only the owner thread can insert an item to the queue.
typename O
typename C
void void tf::BoundedTaskQueue< T, LogSize >::push (O &&item, C &&on_full) push tf::BoundedTaskQueue::push O && item C && on_full

tries to insert an item to the queue or invoke the callable if fails

O

data type

C

callable type

item

the item to perfect-forward to the queue

on_full

callable to invoke when the queue is faull (insertion fails)

Only the owner thread can insert an item to the queue.
T T tf::BoundedTaskQueue< T, LogSize >::pop () pop tf::BoundedTaskQueue::pop

pops out an item from the queue

Only the owner thread can pop out an item from the queue. The return can be a std::nullopt if this operation failed (empty queue).

T T tf::BoundedTaskQueue< T, LogSize >::steal () steal tf::BoundedTaskQueue::steal

steals an item from the queue

Any threads can try to steal an item from the queue. The return can be a std::nullopt if this operation failed (not necessary empty).

class to create a lock-free bounded work-stealing queue

T

data type

LogSize

the base-2 logarithm of the queue size

This class implements the work-stealing queue described in the paper, "Correct and Efficient Work-Stealing for Weak Memory Models," available at https://www.di.ens.fr/~zappa/readings/ppopp13.pdf.

Only the queue owner can perform pop and push operations, while others can steal data from the queue.

- tf::BoundedTaskQueue
  _bottom
- tf::BoundedTaskQueue
  _buffer
- tf::BoundedTaskQueue
  _top
- tf::BoundedTaskQueue
  BoundedTaskQueue
- tf::BoundedTaskQueue
  BufferMask
- tf::BoundedTaskQueue
  BufferSize
- tf::BoundedTaskQueue
  capacity
- tf::BoundedTaskQueue
  empty
- tf::BoundedTaskQueue
  pop
- tf::BoundedTaskQueue
  push
- tf::BoundedTaskQueue
  size
- tf::BoundedTaskQueue
  steal
- tf::BoundedTaskQueue
  try_push
- tf::BoundedTaskQueue
  ~BoundedTaskQueue