Support Class Library
A set of tools providing classes and utility
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
scl::async::Channel< T, Lock, Guard, Container > Class Template Reference

A channel to use for asynchronous communication of data in a queued manner. More...

#include "Channel.h"

Collaboration diagram for scl::async::Channel< T, Lock, Guard, Container >:
Collaboration graph
[legend]

Public Types

using lock_type = Lock
 lock_type The type of locks used in the channel More...
 
template<class L >
using guard_type = Guard< L >
 
using queue_type = std::queue< T, Container >
 queue_type The type of the channel's queue More...
 
using value_type = typename queue_type::value_type
 The type of values exposed through the channel. More...
 
using size_type = typename queue_type::size_type
 The type used to quantize the size of the queue. More...
 
using sender_type = details::ChannelSender< Channel >
 The type of senders for the channel. More...
 
using receiver_type = details::ChannelReceiver< Channel >
 The type of receivers for the channel. More...
 
using transport_traits = details::channel_transport_traits< Channel >
 The type of the transport traits for the channel. More...
 
using transport_type = typename transport_traits::type
 The type of the transport payload. More...
 

Public Member Functions

 Channel ()
 Construct a channel. More...
 
 Channel (const Channel &)=delete
 
 Channel (Channel &&)=delete
 
Channeloperator= (const Channel &)=delete
 
Channeloperator= (Channel &&)=delete
 
size_type size () const
 Retrieve the size of the queue. More...
 
size_type length () const
 Alias for Channel::size. More...
 
bool isEmpty () const
 Determine whether or not the channel is currently empty. More...
 
receiver_typereceiver ()
 Get a receiver for this channel. More...
 
sender_typesender ()
 Get a sender for this channel. More...
 
template<class U = value_type>
sender_typeoperator<< (U &&value)
 Forward a value into the channel. More...
 
template<class U = value_type>
receiver_typeoperator>> (U &value)
 Extract a value from the channel. More...
 

Public Attributes

friend sender_type
 
friend receiver_type
 

Protected Member Functions

transport_type interface ()
 Implementation details to get a receiver and sender for this channel. More...
 

Protected Attributes

lock_type lock
 The lock being used for the channel's queue. More...
 
std::condition_variable_any condition
 The condition used to wait for the channel's queue. More...
 
queue_type queue
 The underlying queue used to store data. More...
 
sender_type sender_
 The sender for this channel. More...
 
receiver_type receiver_
 The receiver for this channel. More...
 

Friends

template<size_t I, class U , class L , template< class > class G, class C >
auto std::get (Channel< U, L, G, C > &chan) -> scl::tools::meta ::tuple_element_t< I, typename Channel< U, L, G, C >::transport_type >
 

Detailed Description

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard, class Container = std::deque<T>>
class scl::async::Channel< T, Lock, Guard, Container >

A channel to use for asynchronous communication of data in a queued manner.

Template Parameters
Tbeing the type of values
Lockbeing the type of lock to use
Guardbeing the type of guard to use
Containerbeing the container to use for the queue

Definition at line 18 of file Channel.h.

Member Typedef Documentation

◆ guard_type

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard, class Container = std::deque<T>>
template<class L >
scl::async::Channel< T, Lock, Guard, Container >::guard_type
Template Parameters
Lbeing the type of lock The type of lock guard used in the channel

Definition at line 236 of file Channel.h.

◆ lock_type

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard, class Container = std::deque<T>>
using scl::async::Channel< T, Lock, Guard, Container >::lock_type = Lock

lock_type The type of locks used in the channel

Definition at line 228 of file Channel.h.

◆ queue_type

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard, class Container = std::deque<T>>
using scl::async::Channel< T, Lock, Guard, Container >::queue_type = std::queue<T, Container>

queue_type The type of the channel's queue

Definition at line 242 of file Channel.h.

◆ receiver_type

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard, class Container = std::deque<T>>
scl::async::Channel< T, Lock, Guard, Container >::receiver_type

The type of receivers for the channel.

Definition at line 266 of file Channel.h.

◆ sender_type

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard, class Container = std::deque<T>>
scl::async::Channel< T, Lock, Guard, Container >::sender_type

The type of senders for the channel.

Definition at line 260 of file Channel.h.

◆ size_type

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard, class Container = std::deque<T>>
scl::async::Channel< T, Lock, Guard, Container >::size_type

The type used to quantize the size of the queue.

Definition at line 254 of file Channel.h.

◆ transport_traits

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard, class Container = std::deque<T>>
scl::async::Channel< T, Lock, Guard, Container >::transport_traits

The type of the transport traits for the channel.

Definition at line 272 of file Channel.h.

◆ transport_type

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard, class Container = std::deque<T>>
scl::async::Channel< T, Lock, Guard, Container >::transport_type

The type of the transport payload.

Definition at line 278 of file Channel.h.

◆ value_type

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard, class Container = std::deque<T>>
scl::async::Channel< T, Lock, Guard, Container >::value_type

The type of values exposed through the channel.

Definition at line 248 of file Channel.h.

Constructor & Destructor Documentation

◆ Channel() [1/3]

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard, class Container = std::deque<T>>
scl::async::Channel< T, Lock, Guard, Container >::Channel ( )
inline

Construct a channel.

Definition at line 326 of file Channel.h.

◆ Channel() [2/3]

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard, class Container = std::deque<T>>
scl::async::Channel< T, Lock, Guard, Container >::Channel ( const Channel< T, Lock, Guard, Container > &  )
delete

◆ Channel() [3/3]

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard, class Container = std::deque<T>>
scl::async::Channel< T, Lock, Guard, Container >::Channel ( Channel< T, Lock, Guard, Container > &&  )
delete

Member Function Documentation

◆ interface()

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard, class Container = std::deque<T>>
transport_type scl::async::Channel< T, Lock, Guard, Container >::interface ( )
inlineprotected

Implementation details to get a receiver and sender for this channel.

Returns
the transport payload

Definition at line 318 of file Channel.h.

◆ isEmpty()

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard, class Container = std::deque<T>>
bool scl::async::Channel< T, Lock, Guard, Container >::isEmpty ( ) const
inline

Determine whether or not the channel is currently empty.

Returns
TRUE if it is, FALSE otherwise

Definition at line 354 of file Channel.h.

◆ length()

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard, class Container = std::deque<T>>
size_type scl::async::Channel< T, Lock, Guard, Container >::length ( ) const
inline

Alias for Channel::size.

Definition at line 346 of file Channel.h.

◆ operator<<()

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard, class Container = std::deque<T>>
template<class U = value_type>
sender_type& scl::async::Channel< T, Lock, Guard, Container >::operator<< ( U &&  value)
inline

Forward a value into the channel.

Template Parameters
Ubeing the type of data to forward (defaults to Channel::value_type)
Parameters
valuebeing the value to forward
Returns
a reference to this Channel's ChannelSender

Definition at line 383 of file Channel.h.

◆ operator=() [1/2]

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard, class Container = std::deque<T>>
Channel& scl::async::Channel< T, Lock, Guard, Container >::operator= ( const Channel< T, Lock, Guard, Container > &  )
delete

◆ operator=() [2/2]

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard, class Container = std::deque<T>>
Channel& scl::async::Channel< T, Lock, Guard, Container >::operator= ( Channel< T, Lock, Guard, Container > &&  )
delete

◆ operator>>()

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard, class Container = std::deque<T>>
template<class U = value_type>
receiver_type& scl::async::Channel< T, Lock, Guard, Container >::operator>> ( U &  value)
inline

Extract a value from the channel.

Template Parameters
Ubeing the type to store the data into (defaults to Channel::value_type)
Parameters
valuebeing where to store the data
Returns
a reference to this Channel's ChannelReceiver

Definition at line 394 of file Channel.h.

◆ receiver()

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard, class Container = std::deque<T>>
receiver_type& scl::async::Channel< T, Lock, Guard, Container >::receiver ( )
inline

Get a receiver for this channel.

Returns
the receiver

Definition at line 362 of file Channel.h.

◆ sender()

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard, class Container = std::deque<T>>
sender_type& scl::async::Channel< T, Lock, Guard, Container >::sender ( )
inline

Get a sender for this channel.

Returns
the sender

Definition at line 371 of file Channel.h.

◆ size()

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard, class Container = std::deque<T>>
size_type scl::async::Channel< T, Lock, Guard, Container >::size ( ) const
inline

Retrieve the size of the queue.

Returns
the size of the queue

Definition at line 338 of file Channel.h.

Friends And Related Function Documentation

◆ std::get

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard, class Container = std::deque<T>>
template<size_t I, class U , class L , template< class > class G, class C >
auto std::get ( Channel< U, L, G, C > &  chan) -> scl::tools::meta ::tuple_element_t< I, typename Channel< U, L, G, C >::transport_type >
friend

Member Data Documentation

◆ condition

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard, class Container = std::deque<T>>
std::condition_variable_any scl::async::Channel< T, Lock, Guard, Container >::condition
mutableprotected

The condition used to wait for the channel's queue.

Definition at line 297 of file Channel.h.

◆ lock

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard, class Container = std::deque<T>>
lock_type scl::async::Channel< T, Lock, Guard, Container >::lock
mutableprotected

The lock being used for the channel's queue.

Definition at line 292 of file Channel.h.

◆ queue

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard, class Container = std::deque<T>>
queue_type scl::async::Channel< T, Lock, Guard, Container >::queue
protected

The underlying queue used to store data.

Definition at line 302 of file Channel.h.

◆ receiver_

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard, class Container = std::deque<T>>
receiver_type scl::async::Channel< T, Lock, Guard, Container >::receiver_
protected

The receiver for this channel.

Definition at line 312 of file Channel.h.

◆ receiver_type

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard, class Container = std::deque<T>>
friend scl::async::Channel< T, Lock, Guard, Container >::receiver_type

Definition at line 281 of file Channel.h.

◆ sender_

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard, class Container = std::deque<T>>
sender_type scl::async::Channel< T, Lock, Guard, Container >::sender_
protected

The sender for this channel.

Definition at line 307 of file Channel.h.

◆ sender_type

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard, class Container = std::deque<T>>
friend scl::async::Channel< T, Lock, Guard, Container >::sender_type

Definition at line 280 of file Channel.h.


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