|
cds
2.3.2
|
Michael & Scott blocking queue with fine-grained synchronization schema. More...
#include <cds/container/rwqueue.h>
Data Structures | |
| struct | rebind |
| Rebind template arguments. More... | |
Public Types | |
| typedef T | value_type |
| Type of value to be stored in the queue. | |
| typedef Traits | traits |
| Queue traits. | |
| typedef traits::lock_type | lock_type |
| Locking primitive. | |
| typedef traits::item_counter | item_counter |
| Item counting policy used. | |
| typedef traits::allocator::template rebind< node_type >::other | allocator_type |
| Allocator type used for allocate/deallocate the queue nodes. | |
Public Member Functions | |
| RWQueue () | |
| Makes empty queue. | |
| ~RWQueue () | |
| Destructor clears queue. | |
| bool | enqueue (value_type const &data) |
Enqueues data. Always return true. | |
| bool | enqueue (value_type &&data) |
Enqueues data, move semantics. | |
| template<typename Func > | |
| bool | enqueue_with (Func f) |
Enqueues data to the queue using a functor. More... | |
| template<typename... Args> | |
| bool | emplace (Args &&... args) |
Enqueues data of type value_type constructed with std::forward<Args>(args)... | |
| bool | push (value_type const &val) |
Synonym for enqueue( value_type const& ) function. | |
| bool | push (value_type &&val) |
Synonym for enqueue( value_type&& ) function. | |
| template<typename Func > | |
| bool | push_with (Func f) |
Synonym for enqueue_with() function. | |
| bool | dequeue (value_type &dest) |
Dequeues a value to dest. More... | |
| template<typename Func > | |
| bool | dequeue_with (Func f) |
| Dequeues a value using a functor. More... | |
| bool | pop (value_type &dest) |
Synonym for dequeue() function. | |
| template<typename Func > | |
| bool | pop_with (Func f) |
Synonym for dequeue_with() function. | |
| bool | empty () const |
| Checks if queue is empty. | |
| void | clear () |
| Clears queue. | |
| size_t | size () const |
| Returns queue's item count. More... | |
Michael & Scott blocking queue with fine-grained synchronization schema.
The queue has two different locks: one for reading and one for writing. Therefore, one writer and one reader can simultaneously access to the queue. The queue does not require any garbage collector.
Source
Template arguments
T - value type to be stored in the queueTraits - queue traits, default is rwqueue::traits. You can use rwqueue::make_traits metafunction to make your traits or just derive your traits from rwqueue::traits:
|
inline |
Dequeues a value to dest.
If queue is empty returns false, dest can be corrupted. If queue is not empty returns true, dest contains the value dequeued
|
inline |
Dequeues a value using a functor.
Func is a functor called to copy dequeued value. The functor takes one argument - a reference to removed node:
The functor is called only if the queue is not empty.
|
inline |
Enqueues data to the queue using a functor.
Func is a functor called to create node. The functor f takes one argument - a reference to a new node of type value_type :
|
inline |
Returns queue's item count.
The value returned depends on rwqueue::traits::item_counter. For atomicity::empty_item_counter, this function always returns 0.
empty() method.