Mercury Currency Engine
Classes | Public Types | Public Member Functions | List of all members
mce::base_channel< T > Struct Template Referenceabstract

#include <base_channel.hpp>

Inheritance diagram for mce::base_channel< T >:
Inheritance graph
[legend]

Classes

class  iterator
 

Public Types

typedef T value_type
 template type for channel
 

Public Member Functions

 base_channel (const base_channel< T > *rhs_bc)
 iterator context constructor
 
virtual void construct () const =0
 construct channel context
 
virtual void * context () const =0
 retrieve internal context pointer
 
virtual const std::type_info & type_info () const =0
 retrieve type_info
 
virtual void close () const =0
 close channel
 
virtual bool closed () const =0
 report if channel is closed
 
virtual bool send (const T &s) const =0
 send a copy of data through channel
 
virtual bool send (T &&s) const =0
 move data through channel
 
virtual bool recv (T &r) const =0
 retrieve data from channel
 
virtual result try_send (const T &s) const =0
 attempt to send a copy of data through channel
 
virtual result try_send (T &&s) const =0
 attempt to move data through channel
 
virtual result try_recv (T &r) const =0
 attempt to retrieve data from channel
 
iterator begin () const
 iterator to the current beginning of the channel
 
iterator end () const
 default iterator == end()
 

Detailed Description

template<typename T>
struct mce::base_channel< T >

Channels must implement this pure virtual interface to be a valid channel object for purposes of 'chan' wrapper.

For clarification, the reason all operations and returned references are const is because channels are designed to ignore const designations. This is because Channels are designed as a trivially easy mechanism for communication and are intended to be copied by capture in lambdas. Unfortunately, unless the lambda in question is designated "mutable" the captures will become const by default, which would make channels useless.

While this design quirk is certainly an anti-pattern, it exists to combat the greater anti pattern of having to mark every user lambda as mutable (which also limits the usable forms of lambda notation). So for the sake simplicity and readability all derived channels which inherit base_channel will typically need to specify its members as mutable.


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