the \( p^2 \) bounded queues of the pairs of workers [see SPSCQueue.h]
More...
#include <ADS/parallel/Channels.h>
|
| using | Message = Msg |
| | the type of the messages
|
|
| | MeshChannels (std::size_t p, std::size_t c=1024) |
| | the \( p^2 \) queues of \( p \) workers, of capacity \( c \) 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 first messages of \( m \) that fit in the queue from from to to, pushed by one store of its tail, and their number
|
| template<class F> |
| std::size_t | drain (std::size_t me, F &&f) |
| | the calls f( x ) on the messages of the \( p \) queues to me, from a sender that turns at each call, and their number
|
| ChannelPort< MeshChannels > | port (std::size_t i) |
| | the channels seen by the worker \( i \)
|
|
| static constexpr bool | bounded = true |
| | whether a push may push fewer messages than given
|
template<class Msg>
class ADS::MeshChannels< Msg >
the \( p^2 \) bounded queues of the pairs of workers [see SPSCQueue.h]
◆ Message
◆ MeshChannels()
the \( p^2 \) queues of \( p \) workers, of capacity \( c \) each
- Precondition
- \( p \ge 1 \), \( c \ge 2 \) a power of 2
◆ drain()
template<class Msg>
template<class F>
the calls f( x ) on the messages of the \( p \) queues to me, from a sender that turns at each call, and their number
In pseudocode (beyond the book), \( s \) the first sender 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{for}\ j \gets 0\ \textbf{to}\ p - 1\ \textbf{do}
\ n \gets n + \mathrm{consume}( Q_{( s + j ) \bmod p , \mathit{me}}
, f ) \cr
4 & \quad s \gets ( s + 1 ) \bmod p;\ \textbf{return}\ n
\end{array}}
\]
- Precondition
- me is a worker
◆ port()
the channels seen by the worker \( i \)
◆ size()
the number \( p \) of the workers
◆ tryPush()
template<class Msg>
| std::size_t ADS::MeshChannels< Msg >::tryPush |
( |
std::size_t | from, |
|
|
std::size_t | to, |
|
|
std::span< const Msg > | m ) |
|
inline |
the first messages of \( m \) that fit in the queue from from to to, pushed by one store of its tail, and their number
In pseudocode (beyond the book), \( Q_{\mathit{from} ,
\mathit{to}} \) the queue of the pair:
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{function}\ \mathrm{tryPush}( \mathit{from} , \mathit{to} , m
) \cr
2 & \quad \textbf{return}\ \mathrm{pushMany}( Q_{\mathit{from} ,
\mathit{to}} , m )
\end{array}}
\]
- Precondition
- from and to are workers
◆ bounded
whether a push may push fewer messages than given
The documentation for this class was generated from the following file: