template<typename T>
requires std::is_copy_constructible_v<T> && std::is_move_constructible_v<T> && std::is_default_constructible_v<T>
class marvin::containers::fifos::SPSC< T >
A thread-safe, realtime-safe single producer single consumer fifo.
A wrapper around cameron314's readerwriterqueue.
Suitable for passing data between two threads. If the queue is full, pushing will have no effect, and if the queue is empty, popping will return a std::nullopt
.
T
must be default-constructible, copy constructible and move constructible.
To empty the queue in a single loop:
class SomeClass {
public:
while(std::optional<int> current = m_fifo.tryPop()) {
std::cout << "Dequeued " << *current << "\n";
}
}
private:
marvin::utils::fifos::SPSC<int> m_fifo;
};
void emptyQueue() noexcept
Definition marvin_FIFO.h:73