Thrill  0.1
Connection Class Referencefinal

Detailed Description

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().

Definition at line 41 of file group.hpp.

+ Inheritance diagram for Connection:
+ Collaboration diagram for Connection:

#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...
 
Groupgroup_ = 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
 

Member Function Documentation

◆ InboundMsg()

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().

◆ Initialize()

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_.

◆ IsValid()

bool IsValid ( ) const
inlinefinalvirtual

◆ OutputOstream()

std::ostream & OutputOstream ( std::ostream &  os) const
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().

◆ RecvNext()

net::Buffer RecvNext ( )
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().

◆ RecvOne()

ssize_t RecvOne ( void *  out_data,
size_t  size 
)
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().

◆ SendOne()

ssize_t SendOne ( const void *  data,
size_t  size,
Flags  flags = NoFlags 
)
finalvirtual

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().

◆ SyncRecv()

void SyncRecv ( void *  out_data,
size_t  size 
)
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().

◆ SyncRecvSend()

void SyncRecvSend ( const void *  send_data,
size_t  send_size,
void *  recv_data,
size_t  recv_size 
)
finalvirtual

Implements Connection.

Definition at line 122 of file group.cpp.

References Connection::NoFlags, Connection::SyncRecv(), and Connection::SyncSend().

Referenced by Connection::IsValid().

◆ SyncSend()

void SyncSend ( const void *  data,
size_t  size,
Flags  flags = NoFlags 
)
finalvirtual

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().

◆ SyncSendRecv()

void SyncSendRecv ( const void *  send_data,
size_t  send_size,
void *  recv_data,
size_t  recv_size 
)
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().

◆ ToString()

std::string ToString ( ) const
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().

Member Data Documentation

◆ d_

std::unique_ptr<Data> d_
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().

◆ group_

Group* group_ = nullptr
private

Reference to our group.

Definition at line 93 of file group.hpp.

Referenced by Connection::Initialize(), Connection::OutputOstream(), and Connection::SyncSend().

◆ peer_

size_t peer_ = size_t(-1)
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().


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