Delen via


concurrent_priority_queue Class

The concurrent_priority_queue class is a container that allows multiple threads to concurrently push and pop items. Items are popped in priority order where priority is determined by a functor supplied as a template argument.

template <
   typename _Ty,
   typename _Compare=std::less<_Ty>,
   typename _Ax = std::allocator<_Ty>
>
, typename _Ax = std::allocator<_Ty> > class concurrent_priority_queue;

Parameters

  • _Ty
    The data type of the elements to be stored in the priority queue.

  • _Compare
    The type of the function object that can compare two element values as sort keys to determine their relative order in the priority queue. This argument is optional and the binary predicate less<_Ty**>** is the default value.

  • _Ax
    The type that represents the stored allocator object that encapsulates details about the allocation and deallocation of memory for the concurrent priority 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 priority queue.

const_reference

A type that represents a const reference to an element of the type stored in a concurrent priority queue.

reference

A type that represents a reference to an element of the type stored in a concurrent priority queue.

size_type

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

value_type

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

Public Constructors

Name

Description

concurrent_priority_queue::concurrent_priority_queue Constructor

Overloaded. Constructs a concurrent priority queue.

Public Methods

Name

Description

concurrent_priority_queue::clear Method

Erases all elements in the concurrent priority. This method is not concurrency-safe.

concurrent_priority_queue::empty Method

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

concurrent_priority_queue::get_allocator Method

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

concurrent_priority_queue::push Method

Overloaded. Adds an element to the concurrent priority queue. This method is concurrency-safe.

concurrent_priority_queue::size Method

Returns the number of elements in the concurrent priority queue. This method is concurrency-safe.

concurrent_priority_queue::swap Method

Swaps the contents of two concurrent priority queues. This method is not concurrency-safe.

concurrent_priority_queue::try_pop Method

Removes and returns the highest priority element from the queue if the queue is non-empty. This method is concurrency-safe.

Public Operators

Name

Description

concurrent_priority_queue::operator= Operator

Overloaded. Assigns the contents of another concurrent_priority_queue object to this one. This method is not concurrency-safe.

Remarks

For detailed information on the concurrent_priority_queue class, see Parallel Containers and Objects.

Inheritance Hierarchy

concurrent_priority_queue

Requirements

Header: concurrent_priority_queue.h

Namespace: concurrency

See Also

Reference

concurrency Namespace

Concepts

Parallel Containers and Objects