FairMQ  1.2.0
C++ Message Passing Framework
Public Member Functions | Friends | List of all members
FairMQChannel Class Reference

Public Member Functions

 FairMQChannel ()
 Default constructor.
 
 FairMQChannel (const std::string &type, const std::string &method, const std::string &address)
 
 FairMQChannel (const std::string &name, const std::string &type, std::shared_ptr< FairMQTransportFactory > factory)
 
 FairMQChannel (const FairMQChannel &)
 Copy Constructor.
 
FairMQChanneloperator= (const FairMQChannel &)
 Assignment operator.
 
virtual ~FairMQChannel ()
 Default destructor.
 
FairMQSocket const & GetSocket () const
 
auto Bind (const std::string &address) -> bool
 
auto Connect (const std::string &address) -> void
 
std::string GetChannelName () const
 
std::string GetChannelPrefix () const
 
std::string GetChannelIndex () const
 
std::string GetType () const
 
std::string GetMethod () const
 
std::string GetAddress () const
 
std::string GetTransport () const
 
int GetSndBufSize () const
 
int GetRcvBufSize () const
 
int GetSndKernelSize () const
 
int GetRcvKernelSize () const
 
int GetRateLogging () const
 
void UpdateType (const std::string &type)
 
void UpdateMethod (const std::string &method)
 
void UpdateAddress (const std::string &address)
 
void UpdateTransport (const std::string &transport)
 
void UpdateSndBufSize (const int sndBufSize)
 
void UpdateRcvBufSize (const int rcvBufSize)
 
void UpdateSndKernelSize (const int sndKernelSize)
 
void UpdateRcvKernelSize (const int rcvKernelSize)
 
void UpdateRateLogging (const int rateLogging)
 
void UpdateChannelName (const std::string &name)
 
bool IsValid () const
 
bool ValidateChannel ()
 
void ResetChannel ()
 Resets the channel (requires validation to be used again).
 
int Send (std::unique_ptr< FairMQMessage > &msg) const
 
int Receive (std::unique_ptr< FairMQMessage > &msg) const
 
int Send (std::unique_ptr< FairMQMessage > &msg, int sndTimeoutInMs) const
 
int Receive (std::unique_ptr< FairMQMessage > &msg, int rcvTimeoutInMs) const
 
int SendAsync (std::unique_ptr< FairMQMessage > &msg) const
 
int ReceiveAsync (std::unique_ptr< FairMQMessage > &msg) const
 
int64_t Send (std::vector< std::unique_ptr< FairMQMessage >> &msgVec) const
 
int64_t Receive (std::vector< std::unique_ptr< FairMQMessage >> &msgVec) const
 
int64_t Send (std::vector< std::unique_ptr< FairMQMessage >> &msgVec, int sndTimeoutInMs) const
 
int64_t Receive (std::vector< std::unique_ptr< FairMQMessage >> &msgVec, int rcvTimeoutInMs) const
 
int64_t SendAsync (std::vector< std::unique_ptr< FairMQMessage >> &msgVec) const
 
int64_t ReceiveAsync (std::vector< std::unique_ptr< FairMQMessage >> &msgVec) const
 
int64_t Send (FairMQParts &parts) const
 
int64_t Receive (FairMQParts &parts) const
 
int64_t Send (FairMQParts &parts, int sndTimeoutInMs) const
 
int64_t Receive (FairMQParts &parts, int rcvTimeoutInMs) const
 
int64_t SendAsync (FairMQParts &parts) const
 
int64_t ReceiveAsync (FairMQParts &parts) const
 
unsigned long GetBytesTx () const
 
unsigned long GetBytesRx () const
 
unsigned long GetMessagesTx () const
 
unsigned long GetMessagesRx () const
 
auto Transport () const -> const FairMQTransportFactory *
 
template<typename... Args>
FairMQMessagePtr NewMessage (Args &&... args) const
 
template<typename T >
FairMQMessagePtr NewSimpleMessage (const T &data) const
 
template<typename T >
FairMQMessagePtr NewStaticMessage (const T &data) const
 

Friends

class FairMQDevice
 

Constructor & Destructor Documentation

◆ FairMQChannel() [1/2]

FairMQChannel::FairMQChannel ( const std::string &  type,
const std::string &  method,
const std::string &  address 
)

Constructor

Parameters
typeSocket type (push/pull/pub/sub/spub/xsub/pair/req/rep/dealer/router/)
methodSocket method (bind/connect)
addressNetwork address to bind/connect to (e.g. "tcp://127.0.0.1:5555" or "ipc://abc")

◆ FairMQChannel() [2/2]

FairMQChannel::FairMQChannel ( const std::string &  name,
const std::string &  type,
std::shared_ptr< FairMQTransportFactory factory 
)

Constructor

Parameters
nameChannel name
typeSocket type (push/pull/pub/sub/spub/xsub/pair/req/rep/dealer/router/)
factoryTransportFactory

Member Function Documentation

◆ GetAddress()

string FairMQChannel::GetAddress ( ) const

Get socket address (e.g. "tcp://127.0.0.1:5555" or "ipc://abc")

Returns
Returns socket address (e.g. "tcp://127.0.0.1:5555" or "ipc://abc")

◆ GetChannelIndex()

string FairMQChannel::GetChannelIndex ( ) const

Get channel index

Returns
Returns channel index (e.g. 0 in "data[0]")

◆ GetChannelName()

string FairMQChannel::GetChannelName ( ) const

Get channel name

Returns
Returns full channel name (e.g. "data[0]")

◆ GetChannelPrefix()

string FairMQChannel::GetChannelPrefix ( ) const

Get channel prefix

Returns
Returns channel prefix (e.g. "data" in "data[0]")

◆ GetMethod()

string FairMQChannel::GetMethod ( ) const

Get socket method

Returns
Returns socket method (bind/connect)

◆ GetRateLogging()

int FairMQChannel::GetRateLogging ( ) const

Get socket rate logging interval (in seconds)

Returns
Returns socket rate logging interval (in seconds)

◆ GetRcvBufSize()

int FairMQChannel::GetRcvBufSize ( ) const

Get socket receive buffer size (in number of messages)

Returns
Returns socket receive buffer size (in number of messages)

◆ GetRcvKernelSize()

int FairMQChannel::GetRcvKernelSize ( ) const

Get socket kernel transmit receive buffer size (in bytes)

Returns
Returns socket kernel transmit receive buffer size (in bytes)

◆ GetSndBufSize()

int FairMQChannel::GetSndBufSize ( ) const

Get socket send buffer size (in number of messages)

Returns
Returns socket send buffer size (in number of messages)

◆ GetSndKernelSize()

int FairMQChannel::GetSndKernelSize ( ) const

Get socket kernel transmit send buffer size (in bytes)

Returns
Returns socket kernel transmit send buffer size (in bytes)

◆ GetTransport()

string FairMQChannel::GetTransport ( ) const

Get channel transport ("default", "zeromq", "nanomsg" or "shmem")

Returns
Returns channel transport (e.g. "default", "zeromq", "nanomsg" or "shmem")

◆ GetType()

string FairMQChannel::GetType ( ) const

Get socket type

Returns
Returns socket type (push/pull/pub/sub/spub/xsub/pair/req/rep/dealer/router/)

◆ IsValid()

bool FairMQChannel::IsValid ( ) const

Checks if the configured channel settings are valid (checks the validity parameter, without running full validation (as oposed to ValidateChannel()))

Returns
true if channel settings are valid, false otherwise.

◆ Receive() [1/2]

int FairMQChannel::Receive ( std::unique_ptr< FairMQMessage > &  msg,
int  rcvTimeoutInMs 
) const

Receives a message from the socket queue.

Receive method attempts to receive a message from the input queue. If the queue is empty the method blocks.

Parameters
msgConstant reference of unique_ptr to a FairMQMessage
Returns
Number of bytes that have been received. -2 If reading from the queue was not possible or timed out. In case of errors, returns -1.

◆ Receive() [2/2]

int64_t FairMQChannel::Receive ( std::vector< std::unique_ptr< FairMQMessage >> &  msgVec,
int  rcvTimeoutInMs 
) const

Receive a vector of messages

Parameters
msgVecmessage vector reference
Returns
Number of bytes that have been received. -2 If reading from the queue was not possible or timed out. In case of errors, returns -1.

◆ ReceiveAsync() [1/2]

int FairMQChannel::ReceiveAsync ( std::unique_ptr< FairMQMessage > &  msg) const

Receives a message in non-blocking mode.

Parameters
msgConstant reference of unique_ptr to a FairMQMessage
Returns
Number of bytes that have been received. If queue is empty, returns -2. In case of errors, returns -1.

◆ ReceiveAsync() [2/2]

int64_t FairMQChannel::ReceiveAsync ( std::vector< std::unique_ptr< FairMQMessage >> &  msgVec) const

Receives a vector of messages in non-blocking mode.

Parameters
msgVecmessage vector reference
Returns
Number of bytes that have been received. If queue is empty, returns -2. In case of errors, returns -1.

◆ Send() [1/2]

int FairMQChannel::Send ( std::unique_ptr< FairMQMessage > &  msg,
int  sndTimeoutInMs 
) const

Sends a message to the socket queue.

Send method attempts to send a message by putting it in the output queue. If the queue is full or queueing is not possible for some other reason (e.g. no peers connected for a binding socket), the method blocks.

Parameters
msgConstant reference of unique_ptr to a FairMQMessage
Returns
Number of bytes that have been queued. -2 If queueing was not possible or timed out. In case of errors, returns -1.

◆ Send() [2/2]

int64_t FairMQChannel::Send ( std::vector< std::unique_ptr< FairMQMessage >> &  msgVec,
int  sndTimeoutInMs 
) const

Send a vector of messages

Parameters
msgVecmessage vector reference
Returns
Number of bytes that have been queued. -2 If queueing was not possible or timed out. In case of errors, returns -1.

◆ SendAsync() [1/2]

int FairMQChannel::SendAsync ( std::unique_ptr< FairMQMessage > &  msg) const

Sends a message in non-blocking mode.

SendAsync method attempts to send a message without blocking by putting it in the queue.

Parameters
msgConstant reference of unique_ptr to a FairMQMessage
Returns
Number of bytes that have been queued. If queueing failed due to full queue or no connected peers (when binding), returns -2. In case of errors, returns -1.

◆ SendAsync() [2/2]

int64_t FairMQChannel::SendAsync ( std::vector< std::unique_ptr< FairMQMessage >> &  msgVec) const

Sends a vector of message in non-blocking mode.

SendAsync method attempts to send a vector of messages without blocking by putting it them the queue.

Parameters
msgVecmessage vector reference
Returns
Number of bytes that have been queued. If queueing failed due to full queue or no connected peers (when binding), returns -2. In case of errors, returns -1.

◆ UpdateAddress()

void FairMQChannel::UpdateAddress ( const std::string &  address)

Set socket address

Parameters
Socketaddress (e.g. "tcp://127.0.0.1:5555" or "ipc://abc")

◆ UpdateChannelName()

void FairMQChannel::UpdateChannelName ( const std::string &  name)

Set channel name

Parameters
nameArbitrary channel name

◆ UpdateMethod()

void FairMQChannel::UpdateMethod ( const std::string &  method)

Set socket method

Parameters
methodSocket method (bind/connect)

◆ UpdateRateLogging()

void FairMQChannel::UpdateRateLogging ( const int  rateLogging)

Set socket rate logging interval (in seconds)

Parameters
rateLoggingSocket rate logging interval (in seconds)

◆ UpdateRcvBufSize()

void FairMQChannel::UpdateRcvBufSize ( const int  rcvBufSize)

Set socket receive buffer size

Parameters
rcvBufSizeSocket receive buffer size (in number of messages)

◆ UpdateRcvKernelSize()

void FairMQChannel::UpdateRcvKernelSize ( const int  rcvKernelSize)

Set socket kernel transmit receive buffer size (in bytes)

Parameters
rcvKernelSizeSocket receive buffer size (in bytes)

◆ UpdateSndBufSize()

void FairMQChannel::UpdateSndBufSize ( const int  sndBufSize)

Set socket send buffer size

Parameters
sndBufSizeSocket send buffer size (in number of messages)

◆ UpdateSndKernelSize()

void FairMQChannel::UpdateSndKernelSize ( const int  sndKernelSize)

Set socket kernel transmit send buffer size (in bytes)

Parameters
sndKernelSizeSocket send buffer size (in bytes)

◆ UpdateTransport()

void FairMQChannel::UpdateTransport ( const std::string &  transport)

Set channel transport

Parameters
transporttransport string ("default", "zeromq", "nanomsg" or "shmem")

◆ UpdateType()

void FairMQChannel::UpdateType ( const std::string &  type)

Set socket type

Parameters
typeSocket type (push/pull/pub/sub/spub/xsub/pair/req/rep/dealer/router/)

◆ ValidateChannel()

bool FairMQChannel::ValidateChannel ( )

Validates channel configuration

Returns
true if channel settings are valid, false otherwise.

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