3#ifndef MSD_CHANNEL_BLOCKING_ITERATOR_HPP_
4#define MSD_CHANNEL_BLOCKING_ITERATOR_HPP_
20template <
typename Channel>
31 using reference =
const typename Channel::value_type&;
54 explicit blocking_iterator(Channel& chan,
bool is_end =
false) : chan_{&chan}, is_end_{is_end}
56 if (!is_end_ && !chan_->read(value_)) {
68 if (!chan_->read(value_)) {
103template <
typename Channel>
188template <
typename Channel>
blocking_writer_iterator< Channel > back_inserter(Channel &chan)
Creates a blocking iterator for the given channel.
Definition blocking_iterator.hpp:189
An iterator that blocks the current thread, waiting to fetch elements from the channel.
Definition blocking_iterator.hpp:21
std::ptrdiff_t difference_type
Signed integral type for iterator difference.
Definition blocking_iterator.hpp:41
reference operator*()
Returns the latest element retrieved from the channel.
Definition blocking_iterator.hpp:79
blocking_iterator< Channel > & operator++() noexcept
Retrieves the next element from the channel.
Definition blocking_iterator.hpp:66
const value_type * pointer
Pointer type to the value_type.
Definition blocking_iterator.hpp:46
blocking_iterator(Channel &chan, bool is_end=false)
Constructs a blocking iterator from a channel reference.
Definition blocking_iterator.hpp:54
const typename Channel::value_type & reference
Constant reference to the type of the elements stored in the channel.
Definition blocking_iterator.hpp:31
bool operator!=(const blocking_iterator &other)
Makes iteration continue until the channel is closed and empty.
Definition blocking_iterator.hpp:88
std::input_iterator_tag iterator_category
Supporting single-pass reading of elements.
Definition blocking_iterator.hpp:36
typename Channel::value_type value_type
The type of the elements stored in the channel.
Definition blocking_iterator.hpp:26
An output iterator pushes elements into a channel. Blocking until the channel is not full.
Definition blocking_iterator.hpp:104
const value_type & reference
Constant reference to the type of the elements stored in the channel.
Definition blocking_iterator.hpp:114
blocking_writer_iterator operator++(int)
Not applicable (handled by operator=).
Definition blocking_iterator.hpp:175
blocking_writer_iterator & operator++()
Not applicable (handled by operator=).
Definition blocking_iterator.hpp:168
std::output_iterator_tag iterator_category
Supporting writing of elements.
Definition blocking_iterator.hpp:119
blocking_writer_iterator & operator=(reference value)
Writes an element into the channel, blocking until space is available.
Definition blocking_iterator.hpp:145
blocking_writer_iterator & operator*()
Not applicable (handled by operator=).
Definition blocking_iterator.hpp:161
typename Channel::value_type value_type
The type of the elements stored in the channel.
Definition blocking_iterator.hpp:109
std::ptrdiff_t difference_type
Signed integral type for iterator difference.
Definition blocking_iterator.hpp:124
blocking_writer_iterator(Channel &chan)
Constructs a blocking iterator from a channel reference.
Definition blocking_iterator.hpp:136
const value_type * pointer
Pointer type to the value_type.
Definition blocking_iterator.hpp:129