C++ Actor Framework  0.18
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
caf::intrusive::task_queue< Policy > Class Template Reference

A singly-linked FIFO queue for storing tasks of varying size. More...

#include <task_queue.hpp>

Inheritance diagram for caf::intrusive::task_queue< Policy >:
Inheritance graph
Collaboration diagram for caf::intrusive::task_queue< Policy >:
Collaboration graph

Public Types

using policy_type = Policy
 
using value_type = typename policy_type::mapped_type
 
using node_type = typename value_type::node_type
 
using node_pointer = node_type *
 
using pointer = value_type *
 
using const_pointer = const value_type *
 
using reference = value_type &
 
using const_reference = const value_type &
 
using unique_pointer = typename policy_type::unique_pointer
 
using task_size_type = typename policy_type::task_size_type
 
using iterator = forward_iterator< value_type >
 
using const_iterator = forward_iterator< const value_type >
 

Public Member Functions

 task_queue (policy_type p)
 
 task_queue (task_queue &&other)
 
task_queueoperator= (task_queue &&other)
 
policy_type & policy () noexcept
 Returns the policy object.
 
const policy_type & policy () const noexcept
 Returns the policy object.
 
task_size_type total_task_size () const noexcept
 Returns the accumulated size of all stored tasks.
 
bool empty () const noexcept
 Returns whether the queue has no elements.
 
pointer peek () noexcept
 Peeks at the first element in the queue. More...
 
template<class F >
void peek_all (F f) const
 Applies f to each element in the queue.
 
template<class Predicate >
pointer find_if (Predicate pred)
 Tries to find an element in the queue that matches the given predicate.
 
void clear ()
 Removes all elements from the queue.
 
iterator begin () noexcept
 Returns an iterator to the dummy before the first element.
 
const_iterator begin () const noexcept
 Returns an iterator to the dummy before the first element.
 
const_iterator cbegin () const noexcept
 Returns an iterator to the dummy before the first element.
 
iterator end () noexcept
 Returns a pointer to the dummy past the last element.
 
const_iterator end () const noexcept
 Returns a pointer to the dummy past the last element.
 
const_iterator cend () const noexcept
 Returns a pointer to the dummy past the last element.
 
pointer front () noexcept
 Returns a pointer to the first element.
 
pointer back () noexcept
 Returns a pointer to the last element.
 
bool push_back (pointer ptr) noexcept
 Appends ptr to the queue. More...
 
bool push_back (unique_pointer ptr) noexcept
 Appends ptr to the queue. More...
 
template<class... Ts>
bool emplace_back (Ts &&... xs)
 Creates a new element from xs... and appends it.
 
template<class Container >
void prepend (Container &other)
 Transfers all element from other to the front of this queue.
 
template<class Container >
void append (Container &other)
 Transfers all element from other to the back of this queue.
 

Static Public Member Functions

static pointer promote (node_pointer ptr) noexcept
 Casts a node type to its value type.
 

Protected Attributes

node_type head_
 node element pointing to the first element.
 
node_type tail_
 node element pointing past the last element.
 
task_size_type total_task_size_
 Stores the total size of all items in the queue.
 
node_pointer old_last_
 Used for LIFO -> FIFO insertion.
 
node_pointer new_head_
 Used for LIFO -> FIFO insertion.
 
policy_type policy_
 Manipulates instances of T.
 

Detailed Description

template<class Policy>
class caf::intrusive::task_queue< Policy >

A singly-linked FIFO queue for storing tasks of varying size.

This queue is used as a base type for concrete task abstractions such as drr_queue and therefore has no dequeue functions.

Member Function Documentation

◆ peek()

template<class Policy>
pointer caf::intrusive::task_queue< Policy >::peek ( )
noexcept

Peeks at the first element in the queue.

Returns nullptr if the queue is empty.

◆ push_back() [1/2]

template<class Policy>
bool caf::intrusive::task_queue< Policy >::push_back ( pointer  ptr)
noexcept

Appends ptr to the queue.

Precondition
ptr != nullptr

◆ push_back() [2/2]

template<class Policy>
bool caf::intrusive::task_queue< Policy >::push_back ( unique_pointer  ptr)
noexcept

Appends ptr to the queue.

Precondition
ptr != nullptr

The documentation for this class was generated from the following file: