3#ifndef MSD_CHANNEL_BLOCKING_ITERATOR_HPP_
4#define MSD_CHANNEL_BLOCKING_ITERATOR_HPP_
19template <
typename Channel>
30 using reference =
const typename Channel::value_type&;
81 std::unique_lock<std::mutex> lock{chan_.mtx_};
82 chan_.waitBeforeRead(lock);
84 return !(chan_.closed() && chan_.empty());
An iterator that block the current thread, waiting to fetch elements from the channel.
Definition blocking_iterator.hpp:20
std::ptrdiff_t difference_type
Signed integral type for iterator difference.
Definition blocking_iterator.hpp:40
reference operator*()
Retrieves and returns the next element from the channel.
Definition blocking_iterator.hpp:66
blocking_iterator< Channel > operator++() const noexcept
Advances the iterator to the next element.
Definition blocking_iterator.hpp:59
blocking_iterator(Channel &chan)
Constructs a blocking iterator from a channel reference.
Definition blocking_iterator.hpp:52
const value_type * pointer
Pointer type to the value_type.
Definition blocking_iterator.hpp:45
bool operator!=(blocking_iterator< Channel >) const
Makes iteration continue until the channel is closed and empty.
Definition blocking_iterator.hpp:79
const typename Channel::value_type & reference
Constant reference to the type of the elements stored in the channel.
Definition blocking_iterator.hpp:30
std::input_iterator_tag iterator_category
Supporting single-pass reading of elements.
Definition blocking_iterator.hpp:35
typename Channel::value_type value_type
The type of the elements stored in the channel.
Definition blocking_iterator.hpp:25