A sender which writes values to an asynchronous channel.
Public Member Functions | |
| Sender (const Sender &other)=delete | |
| Sender & | operator= (const Sender &other)=delete |
| Sender (Sender &&other) noexcept | |
| Sender & | operator= (Sender &&other) noexcept |
| SendFuture< T > | Send (const T &value) |
| SendFuture< T > | Send (T &&value) |
| ReserveSendFuture< T > | ReserveSend () |
| std::optional< SendReservation< T > > | TryReserveSend () |
| bool | TrySend (const T &value) |
| bool | TrySend (T &&value) |
| Status | BlockingSend (Dispatcher &dispatcher, const T &value, chrono::SystemClock::duration timeout=kWaitForever) |
| Status | BlockingSend (Dispatcher &dispatcher, T &&value, chrono::SystemClock::duration timeout=kWaitForever) |
| void | Disconnect () |
| uint16_t | remaining_capacity () const |
| Returns the remaining capacity of the channel. | |
| uint16_t | capacity () const |
| Returns the maximum capacity of the channel. | |
| bool | is_open () const |
| Returns true if the channel is open. | |
Friends | |
| template<typename U > | |
| class | internal::Channel |
| template<typename U > | |
| std::optional< std::tuple< SpmcChannelHandle< U >, Sender< U > > > | CreateSpmcChannel (Allocator &, uint16_t) |
| template<typename U , uint16_t kCapacity> | |
| std::tuple< SpmcChannelHandle< U >, Sender< U > > | CreateSpmcChannel (ChannelStorage< U, kCapacity > &storage) |
| 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) |
|
inline |
Synchronously attempts to send value to the channel, blocking until space is available or the channel is closed.
This operation blocks the running thread until it is complete. It must not be called from an async context, or it will likely deadlock.
|
inline |
Synchronously attempts to send value to the channel, blocking until space is available or the channel is closed.
This operation blocks the running thread until it is complete. It must not be called from an async context, or it will likely deadlock.
|
inline |
Removes this sender from its channel, preventing it from writing further values.
The channel may remain open if other senders and receivers exist.
|
inline |
Returns a Future<std::optional<SendReservation>> which resolves to a SendReservation which can be used to write count values directly into the channel when space is available.
If the channel is closed, the future resolves to nullopt.
|
inline |
Sends value through the channel, blocking until there is space.
Returns a Future<bool> which resolves to true if the value was successfully sent to the channel, or false if the channel is closed.
Note that a value being sent successfully does not guarantee that it will be read. If all corresponding receivers disconnect, any values still buffered in the channel are lost.
|
inline |
Sends value through the channel, blocking until there is space.
Returns a Future<bool> which resolves to true if the value was successfully sent to the channel, or false if the channel is closed.
Note that a value being sent successfully does not guarantee that it will be read. If all corresponding receivers disconnect, any values still buffered in the channel are lost.
|
inline |
Synchronously attempts to reserve a slot in the channel.
Returns a SendReservation if space is available. Returns std::nullopt if the channel is full or closed.
This operation is thread-safe and may be called from outside of an async context.
|
inline |
Synchronously attempts to send value if there is space in the channel. Returns true if successful. This operation is thread-safe and may be called from outside of an async context.
|
inline |
Synchronously attempts to send value if there is space in the channel. Returns true if successful. This operation is thread-safe and may be called from outside of an async context.
|
friend |
Creates a dynamically allocated single-producer, multi-consumer channel with a fixed storage capacity.
Returns a handle to the channel which may be used to create receivers. After all desired receivers are created, the handle 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.
|
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.