C++ Channel
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
msd::blocking_writer_iterator< Channel > Class Template Reference

An output iterator pushes elements into a channel. Blocking until the channel is not full. 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 value_type &
 Constant reference to the type of the elements stored in the channel.
 
using iterator_category = std::output_iterator_tag
 Supporting writing 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_writer_iterator (Channel &chan)
 Constructs a blocking iterator from a channel reference.
 
blocking_writer_iteratoroperator= (reference value)
 Writes an element into the channel, blocking until space is available.
 
blocking_writer_iteratoroperator* ()
 Not applicable (handled by operator=).
 
blocking_writer_iteratoroperator++ ()
 Not applicable (handled by operator=).
 
blocking_writer_iterator operator++ (int)
 Not applicable (handled by operator=).
 

Detailed Description

template<typename Channel>
class msd::blocking_writer_iterator< Channel >

An output iterator pushes elements into a channel. Blocking until the channel is not full.

Used to integrate with standard algorithms that require an output iterator.

Template Parameters
ChannelType of channel being iterated.

Constructor & Destructor Documentation

◆ blocking_writer_iterator()

template<typename Channel >
msd::blocking_writer_iterator< Channel >::blocking_writer_iterator ( Channel chan)
inlineexplicit

Constructs a blocking iterator from a channel reference.

Parameters
chanReference to the channel this iterator will write into.

Member Function Documentation

◆ operator*()

Not applicable (handled by operator=).

Returns
The iterator itself.
Note
It's uncommon to return a reference to an iterator, but I don't want to return a value from the channel. This iterator is supposed to be used only to write values. I don't know if it's a terrible idea or not, but it looks related to the issue with MSVC in the Transform test in tests/channel_test.cpp.

◆ operator++() [1/2]

Not applicable (handled by operator=).

Returns
The iterator itself.

◆ operator++() [2/2]

Not applicable (handled by operator=).

Returns
The iterator itself.

◆ operator=()

Writes an element into the channel, blocking until space is available.

Parameters
valueThe value to be written into the channel.
Returns
The iterator itself.
Note
There is no effect if the channel is closed.

The documentation for this class was generated from the following file: