C++ Channel
|
An iterator that blocks the current thread, waiting to fetch elements from the channel. More...
#include <blocking_iterator.hpp>
Public Types | |
using | value_type = typename Channel::value_type |
The type of the elements stored in the channel. | |
using | reference = const typename Channel::value_type & |
Constant reference to the type of the elements stored in the channel. | |
using | iterator_category = std::input_iterator_tag |
Supporting single-pass reading of elements. | |
using | difference_type = std::ptrdiff_t |
Signed integral type for iterator difference. | |
using | pointer = const value_type * |
Pointer type to the value_type. | |
Public Member Functions | |
blocking_iterator (Channel &chan, bool is_end=false) | |
Constructs a blocking iterator from a channel reference. | |
blocking_iterator< Channel > & | operator++ () noexcept |
Retrieves the next element from the channel. | |
reference | operator* () |
Returns the latest element retrieved from the channel. | |
bool | operator!= (const blocking_iterator &other) |
Makes iteration continue until the channel is closed and empty. | |
An iterator that blocks the current thread, waiting to fetch elements from the channel.
Used to implement channel range-based for loop.
Channel | Type of channel being iterated. |
|
inlineexplicit |
Constructs a blocking iterator from a channel reference.
chan | Reference to the channel this iterator will iterate over. |
is_end | If true, the iterator is in an end state (no elements to read). |
|
inline |
Makes iteration continue until the channel is closed and empty.
other | Another blocking_iterator to compare with. |
|
inline |
Returns the latest element retrieved from the channel.
|
inlinenoexcept |
Retrieves the next element from the channel.