Group channel¶
Classes¶
Type | Name |
---|---|
class | channel <T, M> C++ Coroutines based channel. |
class | channel_peeker <typename T, typename M> Extension of channel_reader for subroutines. |
class | channel_reader <typename T, typename M> Awaitable type for channel 's read operation. It moves the value from writer coroutine's frame to reader coroutine's frame. |
class | channel_writer <typename T, typename M> Awaitable for channel 's write operation. It exposes a reference to the value forchannel_reader . |
Public Functions¶
Type | Name |
---|---|
void | select (channel< T, M > & ch, Fn && fn) noexcept |
void | select (Ch & ch, Fn && fn, Args &&... args) noexcept |
Public Static Functions¶
Type | Name |
---|---|
void * | internal::poison () noexcept Returns a non-null address that leads access violation. |
Detailed Description¶
Note:
The implementation of channel heavily rely on friend
relationship. The design may make the template code ugly, but is necessary because of 2 behaviors.
channel
is a synchronizes 2 awaitable types,channel_reader
andchannel_writer
.- Those reader/writer exchanges their information before their
resume
of each other.
If user code can become mess because of such relationship, it is strongly recommended to hide channel
internally and open their own interfaces.
Public Functions Documentation¶
function select¶
template<typename T typename T, typename M typename M, typename Fn typename Fn>
void select (
channel < T, M > & ch,
Fn && fn
) noexcept
Note:
If the channel is readable, acquire the value and invoke the function
See also: channel_peeker
function select¶
template<typename... Args, typename Ch typename Ch, typename Fn typename Fn>
void select (
Ch & ch,
Fn && fn,
Args &&... args
) noexcept
Note:
For each pair, peeks a channel and invoke the function with the value if the peek was successful.
See also: test/channel_select_type.cpp
Public Static Functions Documentation¶
function poison¶
static void * internal::poison () noexcept
Note:
Notice that reinterpret_cast
is not constexpr for some compiler.
Returns:
void* non-null address