Queue for sharing items between multiple producers/consumers.
More...
#include <asyncpp/queue.h>
|
| template<typename... Args> |
| | queue (size_t max_size=std::numeric_limits< size_t >::max(), dispatcher *disp=nullptr, Args &&... args) |
| | Construct a new queue.
|
| |
|
| queue (const queue &)=delete |
| |
|
| queue (queue &&) noexcept |
| |
|
queue & | operator= (const queue &)=delete |
| |
|
queue & | operator= (queue &&) noexcept |
| |
| size_t | size () const noexcept |
| | Get the number of items available without suspending.
|
| |
|
bool | empty () const noexcept |
| | True if the queue is empty and calling pop() would suspend.
|
| |
| bool | try_push (T &&value) |
| | Try pushing a new item to the queue.
|
| |
| template<typename... Args> |
| bool | try_emplace (Args &&... args) |
| | Try pushing a new item to the queue.
|
| |
| std::optional< T > | try_pop () |
| | Try poping a item from the queue.
|
| |
|
pop_awaiter | pop () |
| | Pop a value from the queue and suspend if the queue is empty.
|
| |
| push_awaiter | push (T &&value) |
| | Push a value to the queue and suspend if the queue is full.
|
| |
|
void | clear () |
| | Clear the queue.
|
| |
template<typename T, typename TContainer = std::deque<T>>
class asyncpp::queue< T, TContainer >
Queue for sharing items between multiple producers/consumers.
◆ queue()
template<typename T , typename TContainer = std::deque<T>>
template<typename... Args>
| asyncpp::queue< T, TContainer >::queue |
( |
size_t | max_size = std::numeric_limits<size_t>::max(), |
|
|
dispatcher * | disp = nullptr, |
|
|
Args &&... | args ) |
|
inlineexplicit |
Construct a new queue.
- Parameters
-
| max_size | The maximum size of items being stored inside the queue before suspending producers. |
| disp | A default dispatcher to use for resuming pop/push operations |
| args | Arguments passed to the underlying std::queue constructor |
◆ push()
template<typename T , typename TContainer >
Push a value to the queue and suspend if the queue is full.
- Parameters
-
◆ size()
template<typename T , typename TContainer >
Get the number of items available without suspending.
- Returns
- Number of items until
pop() blocks
- Note
- The number returned by size() can exceed the maximum set in the constructor, because it includes tasks suspended in push().
◆ try_emplace()
template<typename T , typename TContainer >
template<typename... Args>
Try pushing a new item to the queue.
- Parameters
-
- Returns
- true if the item was pushed to the queue, false if the queue is full
◆ try_pop()
template<typename T , typename TContainer >
Try poping a item from the queue.
- Returns
- The removed item or std::nullopt if the queue is empty
◆ try_push()
template<typename T , typename TContainer >
Try pushing a new item to the queue.
- Parameters
-
- Returns
- true if the item was pushed to the queue, false if the queue is full
The documentation for this class was generated from the following file: