A handle to a single-producer, single-consumer channel.
Friends | |
| template<typename U > | |
| std::optional< std::tuple< SpscChannelHandle< U >, Sender< U >, Receiver< U > > > | CreateSpscChannel (Allocator &, uint16_t) |
| template<typename U , uint16_t kCapacity> | |
| std::tuple< SpscChannelHandle< U >, Sender< U >, Receiver< U > > | CreateSpscChannel (ChannelStorage< U, kCapacity > &storage) |
|
friend |
Creates a dynamically allocated single-producer, single-consumer channel with a fixed storage capacity.
Returns a handle to the channel alongside the sender and receiver. The handle can be used to forcefully close the channel. If that is not required, it can be dropped without affecting the channel.
All allocation occurs during the creation of the channel. After this function returns, usage of the channel is guaranteed not to allocate. If allocation fails, returns std::nullopt.
The channel remains open as long as at least either a handle, or at least one sender and one receiver exist.