userver: concurrent::GenericQueue< T, QueuePolicy > Class Template Reference
Loading...
Searching...
No Matches
concurrent::GenericQueue< T, QueuePolicy > Class Template Referencefinal

#include <userver/concurrent/queue.hpp>

Detailed Description

template<typename T, typename QueuePolicy>
class concurrent::GenericQueue< T, QueuePolicy >

Queue with single and multi producer/consumer options

See also
Synchronization Primitives
Examples
samples/tcp_full_duplex_service/tcp_full_duplex_service.cpp.

Definition at line 52 of file queue.hpp.

+ Inheritance diagram for concurrent::GenericQueue< T, QueuePolicy >:
+ Collaboration diagram for concurrent::GenericQueue< T, QueuePolicy >:

Classes

class  MultiConsumerSide
 
class  MultiProducerSide
 
class  SingleConsumerSide
 
class  SingleProducerSide
 

Public Types

using ValueType = T
 
using Producer
 
using Consumer
 
using MultiProducer
 
using MultiConsumer
 

Public Member Functions

Producer GetProducer ()
 
MultiProducer GetMultiProducer ()
 
Consumer GetConsumer ()
 
MultiConsumer GetMultiConsumer ()
 
void SetSoftMaxSize (std::size_t max_size)
 Sets the limit on the queue size, pushes over this limit will block.
 
std::size_t GetSoftMaxSize () const
 Gets the limit on the queue size.
 
std::size_t GetSizeApproximate () const
 Gets the approximate size of queue.
 

Static Public Member Functions

static std::shared_ptr< GenericQueueCreate (std::size_t max_size=kUnbounded)
 Create a new queue.
 

Static Public Attributes

static constexpr std::size_t kUnbounded
 

Member Typedef Documentation

◆ Consumer

template<typename T , typename QueuePolicy >
using concurrent::GenericQueue< T, QueuePolicy >::Consumer

◆ MultiConsumer

template<typename T , typename QueuePolicy >
using concurrent::GenericQueue< T, QueuePolicy >::MultiConsumer

◆ MultiProducer

template<typename T , typename QueuePolicy >
using concurrent::GenericQueue< T, QueuePolicy >::MultiProducer

◆ Producer

template<typename T , typename QueuePolicy >
using concurrent::GenericQueue< T, QueuePolicy >::Producer

◆ ValueType

template<typename T , typename QueuePolicy >
using concurrent::GenericQueue< T, QueuePolicy >::ValueType = T

Definition at line 80 of file queue.hpp.

Member Function Documentation

◆ Create()

template<typename T , typename QueuePolicy >
static std::shared_ptr< GenericQueue > concurrent::GenericQueue< T, QueuePolicy >::Create ( std::size_t max_size = kUnbounded)
inlinestatic

Create a new queue.

Definition at line 125 of file queue.hpp.

◆ GetConsumer()

template<typename T , typename QueuePolicy >
Consumer concurrent::GenericQueue< T, QueuePolicy >::GetConsumer ( )
inline

Get a Consumer which makes it possible to read items from the queue. Can be called multiple times. The resulting Consumer is not thread-safe, so you have to use multiple Consumers of the same queue to simultaneously write from multiple coroutines/threads.

Note
Consumer may outlive the queue and producers.

Definition at line 163 of file queue.hpp.

◆ GetMultiConsumer()

template<typename T , typename QueuePolicy >
MultiConsumer concurrent::GenericQueue< T, QueuePolicy >::GetMultiConsumer ( )
inline

Get a MultiConsumer which makes it possible to read items from the queue. Can be called multiple times. The resulting MultiConsumer is thread-safe, so it can be used simultaneously from multiple coroutines/threads.

Note
MultiConsumer may outlive the queue and producers.
Prefer Consumer tokens when possible, because MultiConsumer token incurs some overhead.

Definition at line 177 of file queue.hpp.

◆ GetMultiProducer()

template<typename T , typename QueuePolicy >
MultiProducer concurrent::GenericQueue< T, QueuePolicy >::GetMultiProducer ( )
inline

Get a MultiProducer which makes it possible to push items into the queue. Can be called multiple times. The resulting MultiProducer is thread-safe, so it can be used simultaneously from multiple coroutines/threads.

Note
MultiProducer may outlive the queue and consumers.
Prefer Producer tokens when possible, because MultiProducer token incurs some overhead.

Definition at line 150 of file queue.hpp.

◆ GetProducer()

template<typename T , typename QueuePolicy >
Producer concurrent::GenericQueue< T, QueuePolicy >::GetProducer ( )
inline

Get a Producer which makes it possible to push items into the queue. Can be called multiple times. The resulting Producer is not thread-safe, so you have to use multiple Producers of the same queue to simultaneously write from multiple coroutines/threads.

Note
Producer may outlive the queue and consumers.

Definition at line 136 of file queue.hpp.

◆ GetSizeApproximate()

template<typename T , typename QueuePolicy >
std::size_t concurrent::GenericQueue< T, QueuePolicy >::GetSizeApproximate ( ) const
inline

Gets the approximate size of queue.

Definition at line 194 of file queue.hpp.

◆ GetSoftMaxSize()

template<typename T , typename QueuePolicy >
std::size_t concurrent::GenericQueue< T, QueuePolicy >::GetSoftMaxSize ( ) const
inline

Gets the limit on the queue size.

Definition at line 191 of file queue.hpp.

◆ SetSoftMaxSize()

template<typename T , typename QueuePolicy >
void concurrent::GenericQueue< T, QueuePolicy >::SetSoftMaxSize ( std::size_t max_size)
inline

Sets the limit on the queue size, pushes over this limit will block.

Note
This is a soft limit and may be slightly overrun under load.

Definition at line 186 of file queue.hpp.

Friends And Related Symbol Documentation

◆ Consumer< GenericQueue, ConsumerToken, EmplaceEnabler >

template<typename T , typename QueuePolicy >
friend class Consumer< GenericQueue, ConsumerToken, EmplaceEnabler >
friend

Definition at line 54 of file queue.hpp.

◆ Consumer< GenericQueue, MultiConsumerToken, EmplaceEnabler >

template<typename T , typename QueuePolicy >
friend class Consumer< GenericQueue, MultiConsumerToken, EmplaceEnabler >
friend

Definition at line 54 of file queue.hpp.

◆ Producer< GenericQueue, MultiProducerToken, EmplaceEnabler >

template<typename T , typename QueuePolicy >
friend class Producer< GenericQueue, MultiProducerToken, EmplaceEnabler >
friend

Definition at line 54 of file queue.hpp.

◆ Producer< GenericQueue, ProducerToken, EmplaceEnabler >

template<typename T , typename QueuePolicy >
friend class Producer< GenericQueue, ProducerToken, EmplaceEnabler >
friend

Definition at line 54 of file queue.hpp.

Member Data Documentation

◆ kUnbounded

template<typename T , typename QueuePolicy >
constexpr std::size_t concurrent::GenericQueue< T, QueuePolicy >::kUnbounded
staticconstexpr
Initial value:
=
std::numeric_limits<std::size_t>::max() / 4

Definition at line 91 of file queue.hpp.


The documentation for this class was generated from the following file: