tf::UnboundedTaskQueue class | Taskflow QuickStart

#
#include <taskflow/core/tsq.hpp>
template<typename T>
tf::UnboundedTaskQueue class

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

Template parameters
T | data type (must be a pointer type)

This class implements the work-stealing queue described in the paper, Correct and Efficient Work-Stealing for Weak Memory Models.

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

## Constructors, destructors, conversion operators

UnboundedTaskQueue(int64_t LogSize = TF_DEFAULT_UNBOUNDED_TASK_QUEUE_LOG_SIZE) explicit
  constructs the queue with the given size in the base-2 logarithm
~UnboundedTaskQueue()
  destructs the queue

## Public functions

auto empty() const -> bool noexcept
  queries if the queue is empty at the time of this call
auto size() const -> size_t noexcept
  queries the number of items at the time of this call
auto capacity() const -> int64_t noexcept
  queries the capacity of the queue
void push(T item)
  inserts an item to the queue
auto pop() -> T
  pops out an item from the queue
auto steal() -> T
  steals an item from the queue

## Function documentation

###
template<typename T>
tf::UnboundedTaskQueue<T>::UnboundedTaskQueue(int64_t LogSize = TF_DEFAULT_UNBOUNDED_TASK_QUEUE_LOG_SIZE) explicit

constructs the queue with the given size in the base-2 logarithm

Parameters
LogSize | the base-2 logarithm of the queue size

###
template<typename T>
void tf::UnboundedTaskQueue<T>::push(T item)

inserts an item to the queue

Parameters
item | the item to push to the queue

Only the owner thread can insert an item to the queue. The operation can trigger the queue to resize its capacity if more space is required.

###
template<typename T>
T tf::UnboundedTaskQueue<T>::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 `nullptr` if this operation failed (empty queue).

###
template<typename T>
T tf::UnboundedTaskQueue<T>::steal()

steals an item from the queue

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

Tab / T to search, Esc to close
…

Search for symbols, directories, files, pages or modules. You can omit any prefix from the symbol or file path; adding a `:` or `/` suffix lists all members of given symbol or directory.

Use ↓ / ↑ to navigate through the list, Enter to go. Tab autocompletes common prefix, you can copy a link to the result using ⌘ L while ⌘ M produces a Markdown link.

Sorry, nothing was found.