the inboxes as queues with a lane per sender [see MPSCQueue.h]
More...
#include <ADS/parallel/Channels.h>
|
| using | Message = Msg |
| | the type of the messages
|
|
| | 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 constexpr bool | bounded = false |
| | whether a push may push fewer messages than given
|
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]
◆ Message
template<class Msg, std::size_t B = 256>
◆ LaneChannels()
template<class Msg, std::size_t B = 256>
the inboxes of \( p \) workers, with the \( p \) lanes of each
- Precondition
- \( p \ge 1 \)
◆ drain()
template<class Msg, std::size_t B = 256>
template<class F>
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>
the channels seen by the worker \( i \)
◆ size()
template<class Msg, std::size_t B = 256>
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
◆ bounded
template<class Msg, std::size_t B = 256>
whether a push may push fewer messages than given
The documentation for this class was generated from the following file: