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

the inboxes as queues with a lane per sender [see MPSCQueue.h] More...

#include <ADS/parallel/Channels.h>

Public types

using Message = Msg
 the type of the messages

Public member functions

 LaneChannels (std::size_t p)
 the inboxes of \( p \) workers, with the \( p \) lanes of each
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 lane of from in the inbox of to, 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, lane by lane, and their number
ChannelPort< LaneChannels > 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, std::size_t B = 256>
class ADS::LaneChannels< Msg, B >

the inboxes as queues with a lane per sender [see MPSCQueue.h]

Member typedef documentation

◆ Message

template<class Msg, std::size_t B = 256>
using ADS::LaneChannels< Msg, B >::Message = Msg

the type of the messages

Constructor and destructor documentation

◆ LaneChannels()

template<class Msg, std::size_t B = 256>
ADS::LaneChannels< Msg, B >::LaneChannels ( std::size_t p)
inlineexplicit

the inboxes of \( p \) workers, with the \( p \) lanes of each

Precondition
\( p \ge 1 \)

Member function documentation

◆ drain()

template<class Msg, std::size_t B = 256>
template<class F>
std::size_t ADS::LaneChannels< Msg, B >::drain ( std::size_t me,
F && f )
inline

the calls f( x ) on the messages of the inbox of me, lane by lane, and their number

In pseudocode (beyond the book), \( W \) a buffer of me:

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{drain}( \mathit{me} , f ) \cr 2 & \quad n \gets 0 \cr 3 & \quad \textbf{repeat} \cr 4 & \qquad k \gets \mathrm{popInto}( Q_{\mathit{me}} , W , |W| ); \ n \gets n + k \cr 5 & \qquad \textbf{for}\ j \gets 0\ \textbf{to}\ k - 1\ \textbf{do} \ f( W[ j ] ) \cr 6 & \quad \textbf{until}\ k = 0 \cr 7 & \quad \textbf{return}\ n \end{array}} \]

Precondition
me is a worker

◆ port()

template<class Msg, std::size_t B = 256>
ChannelPort< LaneChannels > ADS::LaneChannels< Msg, B >::port ( std::size_t i)
inlinenodiscard

the channels seen by the worker \( i \)

◆ size()

template<class Msg, std::size_t B = 256>
std::size_t ADS::LaneChannels< Msg, B >::size ( void ) const
inlinenodiscard

the number \( p \) of the workers

◆ tryPush()

template<class Msg, std::size_t B = 256>
std::size_t ADS::LaneChannels< Msg, B >::tryPush ( std::size_t from,
std::size_t to,
std::span< const Msg > m )
inline

the messages of \( m \) pushed to the lane of from in the inbox of to, all of them

In pseudocode (beyond the book):

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{tryPush}( \mathit{from} , \mathit{to} , m ) \cr 2 & \quad \textbf{foreach}\ x \in m\ \textbf{do}\ \mathrm{emplace}( \text{the lane of } \mathit{from} \text{ in } Q_{\mathit{to}} , x ) \cr 3 & \quad \textbf{return}\ |m| \end{array}} \]

Precondition
from and to are workers

Member data documentation

◆ bounded

template<class Msg, std::size_t B = 256>
bool ADS::LaneChannels< Msg, B >::bounded = false
staticconstexpr

whether a push may push fewer messages than given


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