C++ Actor Framework 0.18
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
caf::intrusive::drr_cached_queue< Policy > Class Template Reference

A Deficit Round Robin queue with an internal cache for allowing skipping consumers. More...

#include <drr_cached_queue.hpp>

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 unique_pointer = typename policy_type::unique_pointer
 
using deficit_type = typename policy_type::deficit_type
 
using task_size_type = typename policy_type::task_size_type
 
using list_type = task_queue< policy_type >
 
using cache_type = task_queue< policy_type >
 

Public Member Functions

 drr_cached_queue (policy_type p)
 
 drr_cached_queue (drr_cached_queue &&other)
 
drr_cached_queueoperator= (drr_cached_queue &&other)
 
policy_type & policy () noexcept
 Returns the policy object.
 
const policy_type & policy () const noexcept
 Returns the policy object.
 
deficit_type deficit () const
 
task_size_type total_task_size () const
 Returns the accumulated size of all stored tasks in the list, i.e., tasks that are not in the cache.
 
bool empty () const noexcept
 Returns whether the queue has no uncached tasks.
 
pointer peek () noexcept
 Peeks at the first element of the list.
 
template<class F >
void peek_all (F f) const
 Applies f to each element in the queue, excluding cached elements.
 
template<class Predicate >
pointer find_if (Predicate pred)
 Tries to find the next element in the queue (excluding cached elements) that matches the given predicate.
 
void clear ()
 Removes all elements from the queue.
 
void inc_deficit (deficit_type x) noexcept
 
void flush_cache () noexcept
 
unique_pointer take_front () noexcept
 Takes the first element out of the queue (after flushing the cache) and returns it, ignoring the deficit count.
 
template<class F >
bool consume (F &f) noexcept(noexcept(f(std::declval< value_type & >())))
 Consumes items from the queue until the queue is empty, there is not enough deficit to dequeue the next task or the consumer returns stop.
 
template<class F >
new_round_result new_round (deficit_type quantum, F &consumer) noexcept(noexcept(consumer(std::declval< value_type & >())))
 Run a new round with quantum, dispatching all tasks to consumer.
 
cache_typecache () noexcept
 
list_typeitems () noexcept
 
bool push_back (pointer ptr) noexcept
 Appends ptr to the queue.
 
bool push_back (unique_pointer ptr) noexcept
 Appends ptr to the queue.
 
template<class... Ts>
bool emplace_back (Ts &&... xs)
 Creates a new element from xs... and appends it.
 

Detailed Description

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

A Deficit Round Robin queue with an internal cache for allowing skipping consumers.

Member Function Documentation

◆ consume()

template<class Policy >
template<class F >
bool caf::intrusive::drr_cached_queue< Policy >::consume ( F &  f)
noexcept

Consumes items from the queue until the queue is empty, there is not enough deficit to dequeue the next task or the consumer returns stop.

Returns
true if f consumed at least one item.

◆ push_back() [1/2]

template<class Policy >
bool caf::intrusive::drr_cached_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::drr_cached_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: