STLdoc
STLdocumentation
|
The concurrent_queue
class is a sequence container class that allows first-in, first-out access to its elements. It enables a limited set of concurrency-safe operations, such as push
and try_pop
.
More...
#include <concurrent_queue.h>
Classes | |
class | _Destroyer |
Public Types | |
typedef _Ty | value_type |
A type that represents the data type stored in a concurrent queue. More... | |
typedef _Ax | allocator_type |
A type that represents the allocator class for the concurrent queue. More... | |
typedef _Ty & | reference |
A type that provides a reference to an element stored in a concurrent queue. More... | |
typedef const _Ty & | const_reference |
A type that provides a reference to a const element stored in a concurrent queue for reading and performing const operations. More... | |
typedef std::size_t | size_type |
A type that counts the number of elements in a concurrent queue. More... | |
typedef std::ptrdiff_t | difference_type |
A type that provides the signed distance between two elements in a concurrent queue. More... | |
typedef details::_Concurrent_queue_iterator< concurrent_queue, _Ty > | iterator |
A type that represents a non-thread-safe iterator over the elements in a concurrent queue. More... | |
typedef details::_Concurrent_queue_iterator< concurrent_queue, const _Ty > | const_iterator |
A type that represents a non-thread-safe const iterator over elements in a concurrent queue. More... | |
Public Member Functions | |
concurrent_queue (const allocator_type &_Al=allocator_type()) | |
Constructs a concurrent queue. More... | |
concurrent_queue (const concurrent_queue &_OtherQ, const allocator_type &_Al=allocator_type()) | |
Constructs a concurrent queue. More... | |
concurrent_queue (concurrent_queue &&_OtherQ, const allocator_type &_Al=allocator_type()) | |
Constructs a concurrent queue. More... | |
template<typename _InputIterator > | |
concurrent_queue (_InputIterator _Begin, _InputIterator _End) | |
Constructs a concurrent queue. More... | |
~concurrent_queue () | |
Destroys the concurrent queue. More... | |
void | push (const _Ty &_Src) |
Enqueues an item at tail end of the concurrent queue. This method is concurrency-safe. More... | |
void | push (_Ty &&_Src) |
Enqueues an item at tail end of the concurrent queue. This method is concurrency-safe. More... | |
bool | try_pop (_Ty &_Dest) |
Dequeues an item from the queue if one is available. This method is concurrency-safe. More... | |
size_type | unsafe_size () const |
Returns the number of items in the queue. This method is not concurrency-safe. More... | |
bool | empty () const |
Tests if the concurrent queue is empty at the moment this method is called. This method is concurrency-safe. More... | |
allocator_type | get_allocator () const |
Returns a copy of the allocator used to construct the concurrent queue. This method is concurrency-safe. More... | |
void | clear () |
Clears the concurrent queue, destroying any currently enqueued elements. This method is not concurrency-safe. More... | |
iterator | unsafe_begin () |
Returns an iterator of type iterator or const_iterator to the beginning of the concurrent queue. This method is not concurrency-safe. More... | |
iterator | unsafe_end () |
Returns an iterator of type iterator or const_iterator to the end of the concurrent queue. This method is not concurrency-safe. More... | |
const_iterator | unsafe_begin () const |
Returns an iterator of type iterator or const_iterator to the beginning of the concurrent queue. This method is not concurrency-safe. More... | |
const_iterator | unsafe_end () const |
Returns an iterator of type iterator or const_iterator to the end of the concurrent queue. This method is not concurrency-safe. More... | |
Private Types | |
typedef _Ax::template rebind< char >::other | _Page_allocator_type |
Private Member Functions | |
_Ty & | _Get_ref (_Page &_Pg, size_t _Index) |
virtual void | _Copy_item (_Page &_Dst, size_t _Index, const void *_Src) |
virtual void | _Move_item (_Page &_Dst, size_t _Index, void *_Src) |
virtual void | _Assign_and_destroy_item (void *_Dst, _Page &_Src, size_t _Index) |
virtual _Page * | _Allocate_page () |
virtual void | _Deallocate_page (_Page *_Pg) |
Private Attributes | |
_Page_allocator_type | _My_allocator |
Friends | |
template<typename _Container , typename _Value > | |
class | ::Concurrency::details::_Concurrent_queue_iterator |
Additional Inherited Members | |
Protected Member Functions inherited from Concurrency::details::_Concurrent_queue_base_v4 | |
_CRTIMP2 | _Concurrent_queue_base_v4 (size_t _Item_size) |
virtual _CRTIMP2 | ~_Concurrent_queue_base_v4 () |
_CRTIMP2 void | _Internal_push (const void *_Src) |
_CRTIMP2 void | _Internal_move_push (void *_Src) |
_CRTIMP2 void | _Concurrent_queue_base_v4::_Internal_swap (_Concurrent_queue_base_v4 &other) |
_CRTIMP2 bool | _Internal_pop_if_present (void *_Dst) |
_CRTIMP2 size_t | _Internal_size () const |
_CRTIMP2 bool | _Internal_empty () const |
_CRTIMP2 void | _Internal_finish_clear () |
_CRTIMP2 void | _Internal_throw_exception () const |
Protected Attributes inherited from Concurrency::details::_Concurrent_queue_base_v4 | |
size_t | _Items_per_page |
size_t | _Item_size |
The concurrent_queue
class is a sequence container class that allows first-in, first-out access to its elements. It enables a limited set of concurrency-safe operations, such as push
and try_pop
.
_Ty | The data type of the elements to be stored in the queue. |
_Ax | The type that represents the stored allocator object that encapsulates details about the allocation and deallocation of memory for this concurrent queue. This argument is optional and the default value is allocator< _Ty > . |
For more information, see Parallel Containers and Objects.
|
private |
typedef _Ax Concurrency::concurrent_queue< _Ty, _Ax >::allocator_type |
A type that represents the allocator class for the concurrent queue.
typedef details::_Concurrent_queue_iterator<concurrent_queue,const _Ty> Concurrency::concurrent_queue< _Ty, _Ax >::const_iterator |
A type that represents a non-thread-safe const
iterator over elements in a concurrent queue.
typedef const _Ty& Concurrency::concurrent_queue< _Ty, _Ax >::const_reference |
A type that provides a reference to a const
element stored in a concurrent queue for reading and performing const
operations.
typedef std::ptrdiff_t Concurrency::concurrent_queue< _Ty, _Ax >::difference_type |
A type that provides the signed distance between two elements in a concurrent queue.
typedef details::_Concurrent_queue_iterator<concurrent_queue,_Ty> Concurrency::concurrent_queue< _Ty, _Ax >::iterator |
A type that represents a non-thread-safe iterator over the elements in a concurrent queue.
typedef _Ty& Concurrency::concurrent_queue< _Ty, _Ax >::reference |
A type that provides a reference to an element stored in a concurrent queue.
typedef std::size_t Concurrency::concurrent_queue< _Ty, _Ax >::size_type |
A type that counts the number of elements in a concurrent queue.
typedef _Ty Concurrency::concurrent_queue< _Ty, _Ax >::value_type |
A type that represents the data type stored in a concurrent queue.
|
inlineexplicit |
Constructs a concurrent queue.
_Al | The allocator class to use with this object. |
All constructors store an allocator object _Al and initialize the queue.
The first constructor specifies an empty initial queue and explicitly specifies the allocator type to be used.
The second constructor specifies a copy of the concurrent queue _OtherQ .
The third constructor specifies a move of the concurrent queue _OtherQ .
The fourth constructor specifies values supplied by the iterator range [_Begin , _End ).
Concurrency::concurrent_queue< _Ty, _Ax >::concurrent_queue | ( | const concurrent_queue< _Ty, _Ax > & | _Queue, |
const allocator_type & | _Al = allocator_type() |
||
) |
Constructs a concurrent queue.
_OtherQ | The source concurrent_queue object to copy or move elements from. |
_Al | The allocator class to use with this object. |
All constructors store an allocator object _Al and initialize the queue.
The first constructor specifies an empty initial queue and explicitly specifies the allocator type to be used.
The second constructor specifies a copy of the concurrent queue _OtherQ .
The third constructor specifies a move of the concurrent queue _OtherQ .
The fourth constructor specifies values supplied by the iterator range [_Begin , _End ).
Concurrency::concurrent_queue< _Ty, _Ax >::concurrent_queue | ( | concurrent_queue< _Ty, _Ax > && | _Queue, |
const allocator_type & | _Al = allocator_type() |
||
) |
Constructs a concurrent queue.
_OtherQ | The source concurrent_queue object to copy or move elements from. |
_Al | The allocator class to use with this object. |
All constructors store an allocator object _Al and initialize the queue.
The first constructor specifies an empty initial queue and explicitly specifies the allocator type to be used.
The second constructor specifies a copy of the concurrent queue _OtherQ .
The third constructor specifies a move of the concurrent queue _OtherQ .
The fourth constructor specifies values supplied by the iterator range [_Begin , _End ).
_OtherQ | The source concurrent_queue object to copy or move elements from. |
All constructors store an allocator object _Al and initialize the queue.
The first constructor specifies an empty initial queue and explicitly specifies the allocator type to be used.
The second constructor specifies a copy of the concurrent queue _OtherQ .
The third constructor specifies a move of the concurrent queue _OtherQ .
The fourth constructor specifies values supplied by the iterator range [_Begin , _End ).
|
inline |
Constructs a concurrent queue.
_InputIterator | The type of the input iterator that specifies a range of values. |
_Begin | Position of the first element in the range of elements to be copied. |
_End | Position of the first element beyond the range of elements to be copied. |
All constructors store an allocator object _Al and initialize the queue.
The first constructor specifies an empty initial queue and explicitly specifies the allocator type to be used.
The second constructor specifies a copy of the concurrent queue _OtherQ .
The third constructor specifies a move of the concurrent queue _OtherQ .
The fourth constructor specifies values supplied by the iterator range [_Begin , _End ).
Concurrency::concurrent_queue< _Ty, _Ax >::~concurrent_queue | ( | ) |
Destroys the concurrent queue.
|
inlineprivatevirtual |
Implements Concurrency::details::_Concurrent_queue_base_v4.
|
inlineprivatevirtual |
Implements Concurrency::details::_Concurrent_queue_base_v4.
|
inlineprivatevirtual |
Implements Concurrency::details::_Concurrent_queue_base_v4.
|
inlineprivatevirtual |
Implements Concurrency::details::_Concurrent_queue_base_v4.
|
inlineprivate |
|
inlineprivatevirtual |
Implements Concurrency::details::_Concurrent_queue_base_v4.
void Concurrency::concurrent_queue< _Ty, _Ax >::clear | ( | ) |
Clears the concurrent queue, destroying any currently enqueued elements. This method is not concurrency-safe.
|
inline |
Tests if the concurrent queue is empty at the moment this method is called. This method is concurrency-safe.
true
if the concurrent queue was empty at the moment we looked, false
otherwise. While this method is concurrency-safe with respect to calls to the methods push
, try_pop
, and empty
, the value returned might be incorrect by the time it is inspected by the calling thread.
|
inline |
Returns a copy of the allocator used to construct the concurrent queue. This method is concurrency-safe.
|
inline |
Enqueues an item at tail end of the concurrent queue. This method is concurrency-safe.
_Src | The item to be added to the queue. |
push
is concurrency-safe with respect to calls to the methods push
, try_pop
, and empty
.
|
inline |
Enqueues an item at tail end of the concurrent queue. This method is concurrency-safe.
_Src | The item to be added to the queue. |
push
is concurrency-safe with respect to calls to the methods push
, try_pop
, and empty
.
|
inline |
Dequeues an item from the queue if one is available. This method is concurrency-safe.
_Dest | A reference to a location to store the dequeued item. |
true
if an item was successfully dequeued,false
otherwise. If an item was successfully dequeued, the parameter _Dest receives the dequeued value, the original value held in the queue is destroyed, and this function returns true
. If there was no item to dequeue, this function returns false
without blocking, and the contents of the _Dest parameter are undefined.
try_pop
is concurrency-safe with respect to calls to the methods push
, try_pop
, and empty
.
|
inline |
Returns an iterator of type iterator or const_iterator to the beginning of the concurrent queue. This method is not concurrency-safe.
The iterators for the concurrent_queue
class are primarily intended for debugging, as they are slow, and iteration is not concurrency-safe with respect to other queue operations.
|
inline |
Returns an iterator of type iterator or const_iterator to the beginning of the concurrent queue. This method is not concurrency-safe.
The iterators for the concurrent_queue
class are primarily intended for debugging, as they are slow, and iteration is not concurrency-safe with respect to other queue operations.
|
inline |
Returns an iterator of type iterator or const_iterator to the end of the concurrent queue. This method is not concurrency-safe.
The iterators for the concurrent_queue
class are primarily intended for debugging, as they are slow, and iteration is not concurrency-safe with respect to other queue operations.
|
inline |
Returns an iterator of type iterator or const_iterator to the end of the concurrent queue. This method is not concurrency-safe.
The iterators for the concurrent_queue
class are primarily intended for debugging, as they are slow, and iteration is not concurrency-safe with respect to other queue operations.
|
inline |
Returns the number of items in the queue. This method is not concurrency-safe.
unsafe_size
is not concurrency-safe and can produce incorrect results if called concurrently with calls to the methods push
, try_pop
, and empty
.
|
friend |
|
private |