C++ Channel
Loading...
Searching...
No Matches
Classes | Typedefs | Functions
channel.hpp File Reference
#include "blocking_iterator.hpp"
#include "nodiscard.hpp"
#include "storage.hpp"
#include <condition_variable>
#include <cstdlib>
#include <mutex>
#include <stdexcept>
#include <type_traits>
Include dependency graph for channel.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  msd::closed_channel
 Exception thrown if trying to write on closed channel. More...
 
struct  msd::is_supported_type< T >
 Trait to check if a type is supported by msd::channel. More...
 
struct  msd::is_static_storage< typename, typename >
 Trait to check if a storage type has a static capacity member. More...
 
struct  msd::is_static_storage< Storage, decltype((void) Storage::capacity, void())>
 Trait to check if a storage type has a static capacity member. More...
 
class  msd::channel< T, Storage >
 Thread-safe container for sharing data between threads. More...
 

Typedefs

template<typename T >
using msd::default_storage = queue_storage< T >
 Default storage for msd::channel.
 

Functions

template<typename T , typename Storage >
channel< typename std::decay< T >::type, Storage > & msd::operator<< (channel< typename std::decay< T >::type, Storage > &chan, T &&value)
 Pushes an element into the channel.
 
template<typename T , typename Storage >
channel< T, Storage > & msd::operator>> (channel< T, Storage > &chan, T &out)
 Pops an element from the channel.
 

Typedef Documentation

◆ default_storage

template<typename T >
msd::default_storage

Default storage for msd::channel.

Template Parameters
TThe type of the elements.

Function Documentation

◆ operator<<()

template<typename T , typename Storage >
channel< typename std::decay< T >::type, Storage > & msd::operator<< ( channel< typename std::decay< T >::type, Storage > &  chan,
T &&  value 
)

Pushes an element into the channel.

Parameters
chanChannel to write to.
valueValue to write.
Returns
Instance of channel.
Exceptions
closed_channelif channel is closed.

◆ operator>>()

template<typename T , typename Storage >
channel< T, Storage > & msd::operator>> ( channel< T, Storage > &  chan,
T out 
)

Pops an element from the channel.

Parameters
chanChannel to read from.
outWhere to write read value.
Returns
Instance of channel.