the inboxes as stacks of Treiber of batches [see MPSCInbox.h]
More...
#include <ADS/parallel/Channels.h>
|
| using | Message = Msg |
| | the type of the messages
|
|
| | 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 constexpr bool | bounded = false |
| | whether a push may push fewer messages than given
|
template<class Msg>
class ADS::InboxChannels< Msg >
the inboxes as stacks of Treiber of batches [see MPSCInbox.h]
◆ Message
◆ InboxChannels()
the inboxes of \( p \) workers
- Precondition
- \( p \ge 1 \)
◆ drain()
template<class Msg>
template<class 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
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()
the channels seen by the worker \( i \)
◆ size()
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
◆ bounded
whether a push may push fewer messages than given
The documentation for this class was generated from the following file: