Class channel_reader

template <typename T typename T, typename M typename M>

Class List > channel_reader

Awaitable type for channel 's read operation. It moves the value from writer coroutine's frame to reader coroutine's frame.More...

  • #include <channel.hpp>

Inherited by the following classes: channel_peeker

Public Types

Type Name
typedef channel< T, M > channel_type
typedef T * pointer
typedef T & reference
typedef T value_type

Public Attributes

Type Name
channel_type * chan
Next reader in channel.
channel_reader * next = = nullptr

Public Functions

Type Name
bool await_ready () noexcept const
Lock the channel and find available channel_writer __
auto await_resume () noexcept
Returns value from writer coroutine, and bool indicator for the associtated channel's destruction.
void await_suspend (coroutine_handle< void > coro) noexcept
Push to the channel and wait for channel_writer .
~channel_reader () noexcept

Protected Attributes

Type Name
union channel_reader::@0 @1
Resumeable Handle.
void * frame
Address of value.
pointer ptr

Protected Functions

Type Name
channel_reader (channel_type & ch) noexcept
channel_reader (const channel_reader &) noexcept
channel_reader (channel_reader &&) noexcept
channel_reader & operator= (const channel_reader &) noexcept
channel_reader & operator= (channel_reader &&) noexcept

Detailed Description

void read_from(channel<int>& ch, int& ref, bool ok = false) {
    tie(ref, ok) = co_await ch.read();
    if(ok == false)
        ; // channel is under destruction !!!
}

Template parameters:

  • T type of the element
  • M mutex for the channel

See also: channel_writer

Public Types Documentation

typedef channel_type [1/2]

using channel_reader< T, M >::channel_type =  channel<T, M>;

typedef pointer

using channel_reader< T, M >::pointer =  T*;

typedef reference

using channel_reader< T, M >::reference =  T&;

typedef value_type

using channel_reader< T, M >::value_type =  T;

Public Attributes Documentation

variable chan

channel_type* channel_reader< T, M >::chan;

variable next

channel_reader* channel_reader< T, M >::next;

Public Functions Documentation

function await_ready

inline bool channel_reader::await_ready () noexcept const

Returns:

true Matched with channel_writer

Returns:

false There was no available channel_writer. The channel will be **lock**ed for this case.

function await_resume

inline auto channel_reader::await_resume () noexcept

Returns:

tuple<value_type, bool>

function await_suspend

inline void channel_reader::await_suspend (
    coroutine_handle < void > coro
) noexcept

Note:

The channel will be **unlock**ed after return.

Parameters:

  • coro Remember current coroutine's handle to resume later

See also: await_ready

function ~channel_reader

channel_reader::~channel_reader () noexcept

Protected Attributes Documentation

variable @1

union channel_reader::@0 channel_reader< T, M >::@1;

variable frame

void* channel_reader< T, M >::frame;

variable ptr

pointer channel_reader< T, M >::ptr;

Protected Functions Documentation

function channel_reader [1/3]

inline explicit channel_reader::channel_reader (
    channel_type & ch
) noexcept

function channel_reader [2/3]

channel_reader::channel_reader (
    const channel_reader &
) noexcept

function channel_reader [3/3]

channel_reader::channel_reader (
    channel_reader &&
) noexcept

function operator=

channel_reader & channel_reader::operator= (
    const channel_reader &
) noexcept

function operator=

channel_reader & channel_reader::operator= (
    channel_reader &&
) noexcept

The documentation for this class was generated from the following file interface/coroutine/channel.hpp