libcoro
1.0
Coroutine support library for C++20
|
Implements asychronous queue with support for coroutines. More...
#include <queue.h>
Public Member Functions | |
queue ()=default | |
Construct default queue. More... | |
template<std::convertible_to< QueueImpl > Q> | |
queue (Q &&qimpl) | |
Construct queue - initialize internal queue object. More... | |
queue (const queue &other)=delete | |
The queue is not copyable. More... | |
queue (queue &&other) | |
The queue is movable. More... | |
template<typename ... Args> | |
promise< T >::notify | emplace (Args &&... args) |
Push the item to the queue (emplace) More... | |
auto | push (const T &x) |
Push item to the queue. More... | |
auto | push (T &&x) |
Push item to the queue. More... | |
future< T > | pop () |
Pop the items. More... | |
promise< T >::notify | pop (promise< T > &prom) |
Pop item into a promise. More... | |
std::optional< T > | try_pop () |
Pops item non-blocking way. More... | |
bool | empty () const |
determines whether queue is empty More... | |
std::size_t | size () const |
retrieve current size of the queue More... | |
void | clear () |
remove all items from the queue More... | |
void | close (std::exception_ptr e=nullptr) |
close the queue More... | |
void | reopen () |
Reactivates the queue. More... | |
Implements asychronous queue with support for coroutines.
Asynchronous queue allows to co_await on new items. You can have multiple coroutines reading the same queue (for push-pull)
T | type of item |
QueueImpl | object which implements the queue, default is std::queue. You can use for example some kind of priority queue or stack, however the object must have the same interface as the std::queue |