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::MpscQueue< T > Class Template Referencefinal

#include <userver/concurrent/mpsc_queue.hpp>

+ Inheritance diagram for concurrent::MpscQueue< T >:
+ Collaboration diagram for concurrent::MpscQueue< T >:

Public Types

using ValueType = T
 
using Producer = concurrent::Producer< MpscQueue, ProducerToken, EmplaceEnabler >
 
using Consumer = concurrent::Consumer< MpscQueue, EmplaceEnabler >
 
using MultiProducer = concurrent::Producer< MpscQueue, impl::NoToken, EmplaceEnabler >
 

Public Member Functions

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

Static Public Member Functions

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

Static Public Attributes

static constexpr std::size_t kUnbounded
 

Friends

class Producer< MpscQueue, ProducerToken, EmplaceEnabler >
 
class Consumer< MpscQueue, EmplaceEnabler >
 

Detailed Description

template<typename T>
class concurrent::MpscQueue< T >

Multiple producer, single consumer queue

Example usage:

See also
Synchronization Primitives

Definition at line 73 of file mpsc_queue.hpp.

Member Typedef Documentation

◆ Consumer

template<typename T >
using concurrent::MpscQueue< T >::Consumer = concurrent::Consumer<MpscQueue, EmplaceEnabler>

Definition at line 95 of file mpsc_queue.hpp.

◆ MultiProducer

template<typename T >
using concurrent::MpscQueue< T >::MultiProducer = concurrent::Producer<MpscQueue, impl::NoToken, EmplaceEnabler>

Definition at line 96 of file mpsc_queue.hpp.

◆ Producer

template<typename T >
using concurrent::MpscQueue< T >::Producer = concurrent::Producer<MpscQueue, ProducerToken, EmplaceEnabler>

Definition at line 93 of file mpsc_queue.hpp.

◆ ValueType

template<typename T >
using concurrent::MpscQueue< T >::ValueType = T

Definition at line 91 of file mpsc_queue.hpp.

Member Function Documentation

◆ Create()

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

Create a new queue.

Definition at line 113 of file mpsc_queue.hpp.

◆ GetConsumer()

template<typename T >
MpscQueue< T >::Consumer concurrent::MpscQueue< T >::GetConsumer

Get a Consumer which makes it possible to read items from the queue. Can be called only once. You may not use the Consumer simultaneously from multiple coroutines/threads.

Note
Consumer may outlive the queue and producers.

Definition at line 210 of file mpsc_queue.hpp.

◆ GetMultiProducer()

template<typename T >
MpscQueue< T >::MultiProducer concurrent::MpscQueue< T >::GetMultiProducer

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 the Consumer.

Definition at line 203 of file mpsc_queue.hpp.

◆ GetProducer()

template<typename T >
MpscQueue< T >::Producer concurrent::MpscQueue< T >::GetProducer

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 the Consumer.

Definition at line 195 of file mpsc_queue.hpp.

◆ GetSizeApproximate()

template<typename T >
size_t concurrent::MpscQueue< T >::GetSizeApproximate

Gets the approximate size of queue.

Definition at line 228 of file mpsc_queue.hpp.

◆ GetSoftMaxSize()

template<typename T >
size_t concurrent::MpscQueue< T >::GetSoftMaxSize

Gets the limit on the queue size.

Definition at line 223 of file mpsc_queue.hpp.

◆ SetSoftMaxSize()

template<typename T >
void concurrent::MpscQueue< T >::SetSoftMaxSize ( size_t  size)

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 218 of file mpsc_queue.hpp.

Friends And Related Function Documentation

◆ Consumer< MpscQueue, EmplaceEnabler >

template<typename T >
friend class Consumer< MpscQueue, EmplaceEnabler >
friend

Definition at line 74 of file mpsc_queue.hpp.

◆ Producer< MpscQueue, ProducerToken, EmplaceEnabler >

template<typename T >
friend class Producer< MpscQueue, ProducerToken, EmplaceEnabler >
friend

Definition at line 74 of file mpsc_queue.hpp.

Member Data Documentation

◆ kUnbounded

template<typename T >
constexpr std::size_t concurrent::MpscQueue< T >::kUnbounded
staticconstexpr
Initial value:
=
std::numeric_limits<std::size_t>::max()

Definition at line 88 of file mpsc_queue.hpp.


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