|
bitsim
Model, simulate, estimate and control robots in C++
|
A first-in first-out queue that several threads can push to and pop from. More...
#include <concurrent_queue.h>
Public Types | |
| using | value_type = T |
Public Member Functions | |
| bool | push (T value) |
| Add an item at the back of the queue. | |
| std::optional< T > | try_pop () |
| Take the item at the front of the queue, if there is one, without waiting. | |
| template<typename Rep, typename Period> | |
| std::optional< T > | pop_for (std::chrono::duration< Rep, Period > timeout) |
| Take the item at the front of the queue, waiting at most timeout for one. | |
| std::optional< T > | pop () |
| Take the item at the front of the queue, waiting until there is one. | |
| void | close () |
| Stop accepting items and wake every thread that waits for one. | |
| bool | is_closed () const |
| Whether close() was called. | |
| std::size_t | size () const |
| The number of items in the queue. | |
| bool | empty () const |
| Whether the queue has no items. | |
A first-in first-out queue that several threads can push to and pop from.
The thread pool keeps its tasks in one, and the MQTT subscriber the messages that the client's thread receives. pop() waits for an item; pop_for() waits at most a given time, and try_pop() does not wait. close() wakes every thread that waits: they get what is still in the queue, and then std::nullopt. push() on a closed queue drops the item and returns false.
| using bitsim::utils::concurrency::ConcurrentQueue< T >::value_type = T |
| void bitsim::utils::concurrency::ConcurrentQueue< T >::close | ( | ) |
Stop accepting items and wake every thread that waits for one.
| bool bitsim::utils::concurrency::ConcurrentQueue< T >::empty | ( | ) | const |
Whether the queue has no items.
| bool bitsim::utils::concurrency::ConcurrentQueue< T >::is_closed | ( | ) | const |
Whether close() was called.
| std::optional< T > bitsim::utils::concurrency::ConcurrentQueue< T >::pop | ( | ) |
Take the item at the front of the queue, waiting until there is one.
| std::optional< T > bitsim::utils::concurrency::ConcurrentQueue< T >::pop_for | ( | std::chrono::duration< Rep, Period > | timeout | ) |
Take the item at the front of the queue, waiting at most timeout for one.
| bool bitsim::utils::concurrency::ConcurrentQueue< T >::push | ( | T | value | ) |
Add an item at the back of the queue.
| std::size_t bitsim::utils::concurrency::ConcurrentQueue< T >::size | ( | ) | const |
The number of items in the queue.
| std::optional< T > bitsim::utils::concurrency::ConcurrentQueue< T >::try_pop | ( | ) |
Take the item at the front of the queue, if there is one, without waiting.