Github   Telegram
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends | List of all members
concurrent::GenericQueue< T, MultipleProducer, MultipleConsumer > Class Template Referencefinal

#include <userver/concurrent/queue.hpp>

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

Classes

class  MultiConsumerSide
 
class  MultiProducerSide
 
class  SingleConsumerSide
 
class  SingleProducerSide
 

Public Types

using ValueType = T
 
using Producer = concurrent::Producer< GenericQueue, ProducerToken, EmplaceEnabler >
 
using Consumer = concurrent::Consumer< GenericQueue, EmplaceEnabler >
 
using MultiProducer = concurrent::Producer< GenericQueue, MultiProducerToken, EmplaceEnabler >
 

Public Member Functions

Producer GetProducer ()
 
MultiProducer GetMultiProducer ()
 
Consumer GetConsumer ()
 
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.
 
bool NoMoreConsumers () const
 
bool NoMoreProducers () const
 

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
 

Friends

class Producer< GenericQueue, ProducerToken, EmplaceEnabler >
 
class Producer< GenericQueue, MultiProducerToken, EmplaceEnabler >
 
class Consumer< GenericQueue, EmplaceEnabler >
 

Detailed Description

template<typename T, bool MultipleProducer, bool MultipleConsumer>
class concurrent::GenericQueue< T, MultipleProducer, MultipleConsumer >

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 36 of file queue.hpp.

Member Typedef Documentation

◆ Consumer

template<typename T , bool MultipleProducer, bool MultipleConsumer>
using concurrent::GenericQueue< T, MultipleProducer, MultipleConsumer >::Consumer = concurrent::Consumer<GenericQueue, EmplaceEnabler>

Definition at line 65 of file queue.hpp.

◆ MultiProducer

template<typename T , bool MultipleProducer, bool MultipleConsumer>
using concurrent::GenericQueue< T, MultipleProducer, MultipleConsumer >::MultiProducer = concurrent::Producer<GenericQueue, MultiProducerToken, EmplaceEnabler>

Definition at line 66 of file queue.hpp.

◆ Producer

template<typename T , bool MultipleProducer, bool MultipleConsumer>
using concurrent::GenericQueue< T, MultipleProducer, MultipleConsumer >::Producer = concurrent::Producer<GenericQueue, ProducerToken, EmplaceEnabler>

Definition at line 63 of file queue.hpp.

◆ ValueType

template<typename T , bool MultipleProducer, bool MultipleConsumer>
using concurrent::GenericQueue< T, MultipleProducer, MultipleConsumer >::ValueType = T

Definition at line 61 of file queue.hpp.

Member Function Documentation

◆ Create()

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

Create a new queue.

Definition at line 103 of file queue.hpp.

◆ GetConsumer()

template<typename T , bool MultipleProducer, bool MultipleConsumer>
Consumer concurrent::GenericQueue< T, MultipleProducer, MultipleConsumer >::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 141 of file queue.hpp.

◆ GetMultiProducer()

template<typename T , bool MultipleProducer, bool MultipleConsumer>
MultiProducer concurrent::GenericQueue< T, MultipleProducer, MultipleConsumer >::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 128 of file queue.hpp.

◆ GetProducer()

template<typename T , bool MultipleProducer, bool MultipleConsumer>
Producer concurrent::GenericQueue< T, MultipleProducer, MultipleConsumer >::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 114 of file queue.hpp.

◆ GetSizeApproximate()

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

Gets the approximate size of queue.

Definition at line 165 of file queue.hpp.

◆ GetSoftMaxSize()

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

Gets the limit on the queue size.

Definition at line 162 of file queue.hpp.

◆ NoMoreConsumers()

template<typename T , bool MultipleProducer, bool MultipleConsumer>
bool concurrent::GenericQueue< T, MultipleProducer, MultipleConsumer >::NoMoreConsumers ( ) const
inline

Definition at line 236 of file queue.hpp.

◆ NoMoreProducers()

template<typename T , bool MultipleProducer, bool MultipleConsumer>
bool concurrent::GenericQueue< T, MultipleProducer, MultipleConsumer >::NoMoreProducers ( ) const
inline

Definition at line 238 of file queue.hpp.

◆ SetSoftMaxSize()

template<typename T , bool MultipleProducer, bool MultipleConsumer>
void concurrent::GenericQueue< T, MultipleProducer, MultipleConsumer >::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 157 of file queue.hpp.

Friends And Related Function Documentation

◆ Consumer< GenericQueue, EmplaceEnabler >

template<typename T , bool MultipleProducer, bool MultipleConsumer>
friend class Consumer< GenericQueue, EmplaceEnabler >
friend

Definition at line 39 of file queue.hpp.

◆ Producer< GenericQueue, MultiProducerToken, EmplaceEnabler >

template<typename T , bool MultipleProducer, bool MultipleConsumer>
friend class Producer< GenericQueue, MultiProducerToken, EmplaceEnabler >
friend

Definition at line 39 of file queue.hpp.

◆ Producer< GenericQueue, ProducerToken, EmplaceEnabler >

template<typename T , bool MultipleProducer, bool MultipleConsumer>
friend class Producer< GenericQueue, ProducerToken, EmplaceEnabler >
friend

Definition at line 39 of file queue.hpp.

Member Data Documentation

◆ kUnbounded

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

Definition at line 69 of file queue.hpp.


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