Udostępnij za pośrednictwem


concurrent_queue Class

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, to name a few.

template<
   typename _Ty,
   class _Ax
>
class concurrent_queue: public ::Concurrency::details::_Concurrent_queue_base_v4;

Parameters

  • _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**>**.

Members

Public Typedefs

Name

Description

allocator_type

A type that represents the allocator class for the concurrent queue.

const_iterator

A type that represents a non-thread-safe const iterator over elements in a concurrent queue.

const_reference

A type that provides a reference to a const element stored in a concurrent queue for reading and performing const operations.

difference_type

A type that provides the signed distance between two elements in a concurrent queue.

iterator

A type that represents a non-thread-safe iterator over the elements in a concurrent queue.

reference

A type that provides a reference to an element stored in a concurrent queue.

size_type

A type that counts the number of elements in a concurrent queue.

value_type

A type that represents the data type stored in a concurrent queue.

Public Constructors

Name

Description

concurrent_queue::concurrent_queue Constructor

Overloaded. Constructs a concurrent queue.

concurrent_queue::~concurrent_queue Destructor

Destroys the concurrent queue.

Public Methods

Name

Description

concurrent_queue::clear Method

Clears the concurrent queue, destroying any currently enqueued elements. This method is not concurrency-safe.

concurrent_queue::empty Method

Tests if the concurrent queue is empty at the moment this method is called. This method is concurrency-safe.

concurrent_queue::get_allocator Method

Returns a copy of the allocator used to construct the concurrent queue. This method is concurrency-safe.

concurrent_queue::push Method

Enqueues an item at tail end of the concurrent queue. This method is concurrency-safe.

concurrent_queue::try_pop Method

Dequeues an item from the queue if one is available. This method is concurrency-safe.

concurrent_queue::unsafe_begin Method

Overloaded. Returns an iterator of type iterator or const_iterator to the beginning of the concurrent queue. This method is not concurrency-safe.

concurrent_queue::unsafe_end Method

Overloaded. Returns an iterator of type iterator or const_iterator to the end of the concurrent queue. This method is not concurrency-safe.

concurrent_queue::unsafe_size Method

Returns the number of items in the queue. This method is not concurrency-safe.

Remarks

For more information, see Parallel Containers and Objects.

Inheritance Hierarchy

_Concurrent_queue_base_v4

concurrent_queue

Requirements

Header: concurrent_queue.h

Namespace: Concurrency

See Also

Reference

Concurrency Namespace