#include <userver/concurrent/queue.hpp>
The default queue policy for GenericQueue. Custom queue policies must inherit from it.
Definition at line 40 of file queue.hpp.
|
template<typename T > |
static constexpr std::size_t | GetElementSize (const T &) |
|
◆ GetElementSize()
template<typename T >
static constexpr std::size_t concurrent::DefaultQueuePolicy::GetElementSize |
( |
const T & | | ) |
|
|
inlinestaticconstexpr |
Should return the size of an element, which accounts towards the capacity limit. Only makes sense to set if kHasMaxSize == true
.
For the vast majority of queues, capacity is naturally counted in queue elements, e.g. GetSoftMaxSize() == 1000
means that we want no more than 1000 elements in the queue.
Sometimes we want a more complex limit, e.g. for a queue of strings we want the total number of bytes in all the strings to be limited. In that case we can set the element size equal to its std::size
.
- Note
- Returning anything other than 1 adds some synchronization overhead.
- Warning
- An element changing its capacity while inside the queue is UB.
-
Overflow in the total queue size is UB.
Definition at line 70 of file queue.hpp.
◆ kIsMultipleConsumer
constexpr bool concurrent::DefaultQueuePolicy::kIsMultipleConsumer {false} |
|
staticconstexpr |
If true
, the queue gains support for multiple concurrent consumers, which adds some synchronization overhead.
Definition at line 49 of file queue.hpp.
◆ kIsMultipleProducer
constexpr bool concurrent::DefaultQueuePolicy::kIsMultipleProducer {false} |
|
staticconstexpr |
If true
, the queue gains support for multiple concurrent producers, which adds some synchronization overhead. This also makes the queue non-FIFO, because consumer(s) will randomly prioritize some producers over the other ones.
Definition at line 45 of file queue.hpp.
◆ kMaxSizeMode
Whether the queue has support for max size, which adds some synchronization overhead.
Definition at line 53 of file queue.hpp.
The documentation for this struct was generated from the following file: