Thrill
0.1
|
A virtual connection through the mock network: each Group has p Connections to its peers.
The Connection hands over packets to the peers via SyncSend(), and receives them as InboundMsg().
#include <group.hpp>
Public Member Functions | |
void | InboundMsg (net::Buffer &&msg) |
Method which is called by other peers to enqueue a message. More... | |
void | Initialize (Group *group, size_t peer) |
construct from mock::Group More... | |
Base Status Functions | |
bool | IsValid () const final |
check whether the connection is (still) valid. More... | |
std::string | ToString () const final |
return a string representation of this connection, for user output. More... | |
std::ostream & | OutputOstream (std::ostream &os) const final |
virtual method to output to a std::ostream More... | |
Send Functions | |
void | SyncSend (const void *data, size_t size, Flags=NoFlags) final |
ssize_t | SendOne (const void *data, size_t size, Flags flags=NoFlags) final |
Receive Functions | |
void | SyncRecv (void *out_data, size_t size) final |
ssize_t | RecvOne (void *out_data, size_t size) final |
Paired SendReceive Methods | |
void | SyncSendRecv (const void *send_data, size_t send_size, void *recv_data, size_t recv_size) final |
void | SyncRecvSend (const void *send_data, size_t send_size, void *recv_data, size_t recv_size) final |
Public Member Functions inherited from Connection | |
template<typename T > | |
std::enable_if< std::is_pod< T >::value, void >::type | Send (const T &value) |
template<typename T > | |
std::enable_if< !std::is_pod< T >::value &&data::Serialization< BufferBuilder, T >::is_fixed_size, void >::type | Send (const T &value) |
template<typename T > | |
std::enable_if< !std::is_pod< T >::value &&!data::Serialization< BufferBuilder, T >::is_fixed_size, void >::type | Send (const T &value) |
template<typename T > | |
std::enable_if< std::is_pod< T >::value, void >::type | Receive (T *out_value) |
Receive any serializable POD item T. More... | |
template<typename T > | |
std::enable_if< !std::is_pod< T >::value &&data::Serialization< BufferBuilder, T >::is_fixed_size, void >::type | Receive (T *out_value) |
Receive any serializable non-POD fixed-length item T. More... | |
template<typename T > | |
std::enable_if< !std::is_pod< T >::value &&!data::Serialization< BufferBuilder, T >::is_fixed_size, void >::type | Receive (T *out_value) |
Receive any serializable non-POD fixed-length item T. More... | |
template<typename T > | |
std::enable_if< std::is_pod< T >::value, void >::type | SendReceive (const T *value, T *out_value, size_t n=1) |
SendReceive any serializable POD item T. More... | |
template<typename T > | |
std::enable_if< std::is_pod< T >::value, void >::type | ReceiveSend (const T &value, T *out_value) |
template<typename T > | |
std::enable_if< !std::is_pod< T >::value &&data::Serialization< BufferBuilder, T >::is_fixed_size, void >::type | SendReceive (const T *value, T *out_value, size_t n=1) |
SendReceive any serializable non-POD fixed-length item T. More... | |
template<typename T > | |
std::enable_if< !std::is_pod< T >::value &&data::Serialization< BufferBuilder, T >::is_fixed_size, void >::type | ReceiveSend (const T &value, T *out_value) |
template<typename T > | |
std::enable_if< !std::is_pod< T >::value &&!data::Serialization< BufferBuilder, T >::is_fixed_size, void >::type | SendReceive (const T *value, T *out_value, size_t n=1) |
SendReceive any serializable non-POD fixed-length item T. More... | |
template<typename T > | |
std::enable_if< !std::is_pod< T >::value &&!data::Serialization< BufferBuilder, T >::is_fixed_size, void >::type | ReceiveSend (const T &value, T *out_value) |
template<typename T > | |
std::enable_if< std::is_pod< T >::value, void >::type | SendN (const T *value, size_t n) |
template<typename T > | |
std::enable_if< !std::is_pod< T >::value &&data::Serialization< BufferBuilder, T >::is_fixed_size, void >::type | SendN (const T *value, size_t n) |
template<typename T > | |
std::enable_if< !std::is_pod< T >::value &&!data::Serialization< BufferBuilder, T >::is_fixed_size, void >::type | SendN (const T *value, size_t n) |
template<typename T > | |
std::enable_if< std::is_pod< T >::value, void >::type | ReceiveN (T *out_value, size_t n) |
Receive an array of serializable POD items T. More... | |
template<typename T > | |
std::enable_if< !std::is_pod< T >::value &&data::Serialization< BufferBuilder, T >::is_fixed_size, void >::type | ReceiveN (T *out_value, size_t n) |
Receive an array of serializable non-POD fixed-length items T. More... | |
template<typename T > | |
std::enable_if< !std::is_pod< T >::value &&!data::Serialization< BufferBuilder, T >::is_fixed_size, void >::type | ReceiveN (T *out_value, size_t n) |
Receive an array of serializable non-POD fixed-length items T. More... | |
Private Member Functions | |
net::Buffer | RecvNext () |
some-what internal function to extract the next packet from the queue. More... | |
Private Attributes | |
std::unique_ptr< Data > | d_ |
pimpl data struct with complex components More... | |
Group * | group_ = nullptr |
Reference to our group. More... | |
size_t | peer_ = size_t(-1) |
Outgoing peer id of this Connection. More... | |
Additional Inherited Members | |
Public Types inherited from Connection | |
enum | Flags : size_t { NoFlags = 0, MsgMore = 1 } |
Additional flags for sending or receiving. More... | |
Public Attributes inherited from Connection | |
bool | is_loopback_ = false |
std::atomic< uint32_t > | tx_seq_ { 0 } |
send sequence More... | |
std::atomic< uint32_t > | rx_seq_ { 0 } |
receive sequence More... | |
std::atomic< size_t > | tx_bytes_ { 0 } |
sent bytes More... | |
std::atomic< size_t > | rx_bytes_ = { 0 } |
received bytes More... | |
size_t | prev_tx_bytes_ = 0 |
previous read of sent bytes More... | |
size_t | prev_rx_bytes_ = 0 |
previous read of received bytes More... | |
std::atomic< size_t > | tx_active_ { 0 } |
active send requests More... | |
std::atomic< size_t > | rx_active_ = { 0 } |
active recv requests More... | |
Static Public Attributes inherited from Connection | |
static constexpr bool | self_verify_ = common::g_self_verify |
void InboundMsg | ( | net::Buffer && | msg | ) |
Method which is called by other peers to enqueue a message.
Definition at line 60 of file group.cpp.
References Connection::d_, and Dispatcher::Notify().
void Initialize | ( | Group * | group, |
size_t | peer | ||
) |
construct from mock::Group
Definition at line 53 of file group.cpp.
References Connection::d_, Connection::group_, Connection::is_loopback_, and Connection::peer_.
|
inlinefinalvirtual |
check whether the connection is (still) valid.
Implements Connection.
Definition at line 53 of file group.hpp.
References Connection::NoFlags, Connection::OutputOstream(), Connection::RecvOne(), Connection::SendOne(), Connection::SyncRecv(), Connection::SyncRecvSend(), Connection::SyncSend(), Connection::SyncSendRecv(), and Connection::ToString().
|
finalvirtual |
virtual method to output to a std::ostream
Implements Connection.
Definition at line 72 of file group.cpp.
References Connection::group_, and Connection::peer_.
Referenced by Connection::IsValid().
|
private |
some-what internal function to extract the next packet from the queue.
Definition at line 90 of file group.cpp.
References Connection::d_, Connection::rx_bytes_, and Buffer::size().
Referenced by Connection::SyncRecv().
|
finalvirtual |
Non-blocking receive of at most size data. returns number of bytes actually received. check errno for errors.
Implements Connection.
Definition at line 111 of file group.cpp.
References Connection::SyncRecv().
Referenced by Connection::IsValid().
Non-blocking send of a (data,size) message. returns number of bytes possible to send. check errno for errors.
Implements Connection.
Definition at line 85 of file group.cpp.
References Connection::SyncSend().
Referenced by Connection::IsValid().
|
finalvirtual |
Synchronous blocking receive a message of given size. The size must match the SyncSend size for some network layers may only support matching messages (read: RDMA!, but also true for the mock net). Throws a net::Exception on errors.
Implements Connection.
Definition at line 104 of file group.cpp.
References Buffer::begin(), die_unequal, Buffer::end(), Connection::RecvNext(), and Buffer::size().
Referenced by Connection::IsValid(), Connection::RecvOne(), Connection::SyncRecvSend(), and Connection::SyncSendRecv().
|
finalvirtual |
Implements Connection.
Definition at line 122 of file group.cpp.
References Connection::NoFlags, Connection::SyncRecv(), and Connection::SyncSend().
Referenced by Connection::IsValid().
Synchronous blocking send of the (data,size) packet. if sending fails, a net::Exception is thrown.
Implements Connection.
Definition at line 78 of file group.cpp.
References Connection::group_, Connection::peer_, Group::Send(), and Connection::tx_bytes_.
Referenced by Connection::IsValid(), Connection::SendOne(), Connection::SyncRecvSend(), and Connection::SyncSendRecv().
|
finalvirtual |
Synchronous blocking sending and receive a message of given size. The size must match the SyncSendRecv size for some network layers may only support matching messages (read: RDMA!, but also true for the mock net). Throws a net::Exception on errors.
Implements Connection.
Definition at line 116 of file group.cpp.
References Connection::NoFlags, Connection::SyncRecv(), and Connection::SyncSend().
Referenced by Connection::IsValid().
|
finalvirtual |
return a string representation of this connection, for user output.
Implements Connection.
Definition at line 68 of file group.cpp.
References Connection::peer_, and thrill::mem::to_string().
Referenced by Connection::IsValid().
|
private |
pimpl data struct with complex components
Definition at line 102 of file group.hpp.
Referenced by Dispatcher::AddRead(), Dispatcher::AddWrite(), Dispatcher::DispatchOne(), Connection::InboundMsg(), Connection::Initialize(), and Connection::RecvNext().
|
private |
Reference to our group.
Definition at line 93 of file group.hpp.
Referenced by Connection::Initialize(), Connection::OutputOstream(), and Connection::SyncSend().
|
private |
Outgoing peer id of this Connection.
Definition at line 96 of file group.hpp.
Referenced by Connection::Initialize(), Connection::OutputOstream(), Connection::SyncSend(), and Connection::ToString().