The sending end of a channel.
More...
#include <Channel.hpp>
|
|
| Sender (Sender &&)=default |
|
| Sender (Sender const &)=default |
|
| Sender (Sender const &)=delete |
|
Sender & | operator= (Sender &&)=default |
|
Sender & | operator= (Sender const &)=default |
|
Sender & | operator= (Sender const &)=delete |
template<typename D>
requires (std::convertible_to<std::remove_cvref_t<D>, std::remove_cvref_t<T>>) |
| bool | asyncSend (D &&data, boost::asio::yield_context yield) |
| | Asynchronously sends data through the channel using a coroutine.
|
template<typename D>
requires (std::convertible_to<std::remove_cvref_t<D>, std::remove_cvref_t<T>>) |
| void | asyncSend (D &&data, std::invocable< bool > auto &&fn) |
| | Asynchronously sends data through the channel using a callback.
|
template<typename D>
requires (std::convertible_to<std::remove_cvref_t<D>, std::remove_cvref_t<T>>) |
| bool | trySend (D &&data) |
| | Attempts to send data through the channel without blocking.
|
template<typename T,
ProducerType P = ProducerType::Multi,
ConsumerType C = ConsumerType::Multi>
class util::Channel< T, P, C >::Sender
The sending end of a channel.
Sender is movable. For multi-producer channels, Sender is also copyable. The channel remains open as long as at least one Sender exists. When all Sender instances are destroyed, the channel is closed and receivers will receive std::nullopt.
◆ asyncSend() [1/2]
template<typename D>
requires (std::convertible_to<std::remove_cvref_t<D>, std::remove_cvref_t<T>>)
| bool util::Channel< T, P, C >::Sender::asyncSend |
( |
D && | data, |
|
|
boost::asio::yield_context | yield ) |
|
inline |
Asynchronously sends data through the channel using a coroutine.
Blocks the coroutine until the data is sent or the channel is closed.
- Template Parameters
-
| D | The type of data to send (must be convertible to T) |
- Parameters
-
| data | The data to send |
| yield | The Boost.Asio yield context for coroutine suspension |
- Returns
- true if the data was sent successfully, false if the channel is closed
◆ asyncSend() [2/2]
template<typename D>
requires (std::convertible_to<std::remove_cvref_t<D>, std::remove_cvref_t<T>>)
| void util::Channel< T, P, C >::Sender::asyncSend |
( |
D && | data, |
|
|
std::invocable< bool > auto && | fn ) |
|
inline |
Asynchronously sends data through the channel using a callback.
The callback is invoked when the send operation completes.
- Template Parameters
-
| D | The type of data to send (must be convertible to T) |
- Parameters
-
| data | The data to send |
| fn | Callback function invoked with true if successful, false if the channel is closed |
◆ trySend()
template<typename D>
requires (std::convertible_to<std::remove_cvref_t<D>, std::remove_cvref_t<T>>)
Attempts to send data through the channel without blocking.
- Template Parameters
-
| D | The type of data to send (must be convertible to T) |
- Parameters
-
- Returns
- true if the data was sent successfully, false if the channel is full or closed
The documentation for this class was generated from the following file: