C++ Channel
|
Thread-safe container for sharing data between threads. More...
#include <channel.hpp>
Public Types | |
using | value_type = T |
The type of elements stored in the channel. | |
using | iterator = blocking_iterator< channel< T > > |
The iterator type used to traverse the channel. | |
using | size_type = std::size_t |
The type used to represent sizes and counts. | |
Public Member Functions | |
constexpr | channel ()=default |
Creates an unbuffered channel. | |
constexpr | channel (const size_type capacity) |
Creates a buffered channel. | |
NODISCARD size_type constexpr | size () const noexcept |
Returns the current size of the channel. | |
NODISCARD bool constexpr | empty () const noexcept |
Checks if the channel is empty. | |
void | close () noexcept |
Closes the channel. | |
NODISCARD bool | closed () const noexcept |
Checks if the channel has been closed. | |
iterator | begin () noexcept |
Returns an iterator to the beginning of the channel. | |
iterator | end () noexcept |
Returns an iterator representing the end of the channel. | |
channel (const channel &)=delete | |
channel & | operator= (const channel &)=delete |
channel (channel &&)=delete | |
channel & | operator= (channel &&)=delete |
Friends | |
class | blocking_iterator< channel > |
template<typename Type > | |
channel< typename std::decay< Type >::type > & | operator<< (channel< typename std::decay< Type >::type > &, Type &&) |
Pushes an element into the channel. | |
template<typename Type > | |
channel< Type > & | operator>> (channel< Type > &, Type &) |
Pops an element from the channel. | |
Thread-safe container for sharing data between threads.
Implements a blocking input iterator.
T | The type of the elements. |
|
inlineexplicitconstexpr |
Creates a buffered channel.
capacity | Number of elements the channel can store before blocking. |
Channel cannot be copied or moved.
|
inlinenoexcept |
Returns an iterator to the beginning of the channel.
|
inlinenoexcept |
Checks if the channel has been closed.
|
inlineconstexprnoexcept |
Checks if the channel is empty.
|
inlinenoexcept |
Returns an iterator representing the end of the channel.
|
inlineconstexprnoexcept |
Returns the current size of the channel.
|
friend |
Pushes an element into the channel.
closed_channel | if channel is closed. |
Pops an element from the channel.
Type | The type of the elements |