ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
ADS::InboxChannels< Msg > Class Template Reference

the inboxes as stacks of Treiber of batches [see MPSCInbox.h] More...

#include <ADS/parallel/Channels.h>

Public types

using Message = Msg
 the type of the messages

Public member functions

 InboxChannels (std::size_t p)
 the inboxes of \( p \) workers
std::size_t size (void) const
 the number \( p \) of the workers
std::size_t tryPush (std::size_t from, std::size_t to, std::span< const Msg > m)
 the messages of \( m \) pushed to the inbox of to as one batch, all of them
template<class F>
std::size_t drain (std::size_t me, F &&f)
 the calls f( x ) on the messages of the inbox of me, the batches of each sender in the order of their pushes, and their number
ChannelPort< InboxChannels > port (std::size_t i)
 the channels seen by the worker \( i \)

Static public attributes

static constexpr bool bounded = false
 whether a push may push fewer messages than given

Detailed description

template<class Msg>
class ADS::InboxChannels< Msg >

the inboxes as stacks of Treiber of batches [see MPSCInbox.h]

Member typedef documentation

◆ Message

template<class Msg>
using ADS::InboxChannels< Msg >::Message = Msg

the type of the messages

Constructor and destructor documentation

◆ InboxChannels()

template<class Msg>
ADS::InboxChannels< Msg >::InboxChannels ( std::size_t p)
inlineexplicit

the inboxes of \( p \) workers

Precondition
\( p \ge 1 \)

Member function documentation

◆ drain()

template<class Msg>
template<class F>
std::size_t ADS::InboxChannels< Msg >::drain ( std::size_t me,
F && f )
inline

the calls f( x ) on the messages of the inbox of me, the batches of each sender in the order of their pushes, and their number

In pseudocode (beyond the book):

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{drain}( \mathit{me} , f ) \cr 2 & \quad L \gets \mathrm{take}( I_{\mathit{me}} )\quad \triangleright \ \text{one exchange, the oldest batch first} \cr 3 & \quad \textbf{foreach}\ \text{batch } b \in L\ \textbf{do} \ \textbf{foreach}\ x \in b\ \textbf{do}\ f( x ) \cr 4 & \quad \textbf{return}\ \text{the messages of } L \end{array}} \]

Precondition
me is a worker

◆ port()

template<class Msg>
ChannelPort< InboxChannels > ADS::InboxChannels< Msg >::port ( std::size_t i)
inlinenodiscard

the channels seen by the worker \( i \)

◆ size()

template<class Msg>
std::size_t ADS::InboxChannels< Msg >::size ( void ) const
inlinenodiscard

the number \( p \) of the workers

◆ tryPush()

template<class Msg>
std::size_t ADS::InboxChannels< Msg >::tryPush ( std::size_t from,
std::size_t to,
std::span< const Msg > m )
inline

the messages of \( m \) pushed to the inbox of to as one batch, all of them

In pseudocode (the push of Treiber, beyond the book):

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{tryPush}( \mathit{from} , \mathit{to} , m ) \cr 2 & \quad \mathrm{push}( I_{\mathit{to}} , \text{a copy of } m )\quad \triangleright\ \text{one cell, one CAS} \cr 3 & \quad \textbf{return}\ |m| \end{array}} \]

Precondition
from and to are workers

Member data documentation

◆ bounded

template<class Msg>
bool ADS::InboxChannels< Msg >::bounded = false
staticconstexpr

whether a push may push fewer messages than given


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