wrench::S4U_CommPort

class S4U_CommPort

Wrappers around S4U’s communication methods.

Public Functions

S4U_CommPort()

Constructor.

~S4U_CommPort()

Destructor.

void dputMessage(SimulationMessage *msg)

Asynchronously send a message to a commport in a “fire and forget” fashion.

Parameters:

msg – the SimulationMessage

inline const char *get_cname() const

Return the commport’s name (as a C-style string)

Returns:

the commport’s name

inline const std::string get_name() const

Return the commport’s name (as a C++ string)

Returns:

the commport’s name

template<class TMessageType>
inline std::string get_type_name()

Returns a message type name as a string.

inline std::unique_ptr<SimulationMessage> getMessage()

Synchronously receive a message from a commport_name.

Throws:

std::shared_ptr<NetworkError>

Returns:

the message, or nullptr (in which case it’s likely a brutal termination)

template<class TMessageType>
inline std::unique_ptr<TMessageType> getMessage(const std::string &error_prefix = "")

Synchronously receive a message from a commport_name.

Parameters:

error_prefix – any string you wish to prefix the error message with

Throws:

std::shared_ptr<NetworkError>

Returns:

the message, in a unique_ptr of the type specified. Otherwise throws a runtime_error

inline std::unique_ptr<SimulationMessage> getMessage(double timeout)

Synchronously receive a message from a commport_name, with a timeout.

Parameters:

timeout – a timeout value in seconds (<0 means never timeout)

Throws:

std::shared_ptr<NetworkError>

Returns:

the message, or nullptr (in which case it’s likely a brutal termination)

template<class TMessageType>
inline std::unique_ptr<TMessageType> getMessage(double timeout, const std::string &error_prefix = "")

Synchronously receive a message from a commport.

Parameters:
  • error_prefix – any string you wish to prefix the error message with

  • timeout – a timeout value in seconds (<0 means never timeout)

Throws:

std::shared_ptr<NetworkError>

Returns:

the message, in a unique_ptr of the type specified. Otherwise throws a runtime_error

std::shared_ptr<S4U_PendingCommunication> igetMessage()

Asynchronously receive a message from a commport.

Throws:

std::shared_ptr<NetworkError>

Returns:

a pending communication handle

std::shared_ptr<S4U_PendingCommunication> iputMessage(SimulationMessage *msg)

Asynchronously send a message to a commport.

Parameters:

msg – the SimulationMessage

Throws:

std::shared_ptr<NetworkError>

Returns:

a pending communication handle

void putMessage(SimulationMessage *m)

Synchronously send a message to a commport.

Parameters:

msg – the SimulationMessage

Throws:

std::shared_ptr<NetworkError>

void reset()

Reset all communication.

Public Static Functions

static void createCommPortPool()

Create the pool of commports to use.

static unsigned long generateUniqueSequenceNumber()

Generate a unique sequence number.

Returns:

a unique sequence number

static S4U_CommPort *getTemporaryCommPort()

Get a temporary commport.

Returns:

a temporary commport

static void retireTemporaryCommPort(S4U_CommPort *commport)

Retire a temporary commport.

Parameters:

commport – the commport to retire

Public Static Attributes

static unsigned long commport_pool_size = 5000

The commport_name pool size.

static double default_control_message_size

The default control message size.

static S4U_CommPort *NULL_COMMPORT

The “not a commport_name” commport_name, to avoid getting answers back when asked to prove an “answer commport_name”.