Single producer - single consumer thread-safe, fiber-friendly channel. More...
#include <simple_channel.h>
Public Member Functions | |
SimpleChannel (size_t n) | |
template<typename... Args> | |
void | Push (Args &&... recordArgs) noexcept |
bool | Pop (T &dest) |
void | StartClosing () |
template<typename... Args> | |
bool | TryPush (Args &&... args) noexcept |
Non blocking push. | |
bool | TryPop (T &val) |
Non blocking pop. | |
bool | IsClosing () const |
Single producer - single consumer thread-safe, fiber-friendly channel.
Fiber friendly - means that multiple fibers within a single thread at each end-point can use the channel: K fibers from producer thread can push and N fibers from consumer thread can pull the records. It has optional blocking interface that suspends blocked fibers upon empty/full conditions. This class designed to be pretty efficient by reducing the contention on its synchronization primitives to minimum.
Definition at line 25 of file simple_channel.h.
void util::fibers_ext::SimpleChannel< T >::StartClosing | ( | ) |
/brief Should be called only from the producer side.
Signals the consumers that the channel is going to be close. Consumers may still pop the existing items until Pop() return false. This function does not block, only puts the channel into closing state. It's responsibility of the caller to wait for the consumers to empty the remaining items and stop using the channel.
Definition at line 113 of file simple_channel.h.