wrench::S4U_Mailbox

class S4U_Mailbox

Wrappers around S4U’s communication methods.

Public Static Functions

static void createMailboxPool(unsigned long num_mailboxes)

Create the pool of mailboxes to use.

Parameters:

num_mailboxes – numb mailboxes in pool

static void dputMessage(simgrid::s4u::Mailbox *mailbox, SimulationMessage *msg)

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

Parameters:
static simgrid::s4u::Mailbox *generateUniqueMailbox(const std::string &prefix)

Generate a unique (non-temporary) mailbox.

Parameters:

prefix – mailbox name prefix

Returns:

static unsigned long generateUniqueSequenceNumber()

Generate a unique sequence number.

Returns:

a unique sequence number

static inline std::unique_ptr<SimulationMessage> getMessage(simgrid::s4u::Mailbox *mailbox)

Synchronously receive a message from a mailbox.

Parameters:

mailbox – the mailbox

Throws:

std::shared_ptr<NetworkError>

Returns:

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

template<class TMessageType>
static inline std::unique_ptr<TMessageType> getMessage(simgrid::s4u::Mailbox *mailbox, const std::string &error_prefix = "")

Synchronously receive a message from a mailbox.

Parameters:
  • mailbox – the mailbox

  • 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

static inline std::unique_ptr<SimulationMessage> getMessage(simgrid::s4u::Mailbox *mailbox, double timeout)

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

Parameters:
  • mailbox – the mailbox

  • 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>
static inline std::unique_ptr<TMessageType> getMessage(simgrid::s4u::Mailbox *mailbox, double timeout, const std::string &error_prefix = "")

Synchronously receive a message from a mailbox.

Parameters:
  • mailbox – the mailbox

  • 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

static simgrid::s4u::Mailbox *getTemporaryMailbox()

Get a temporary mailbox.

Returns:

a temporary mailbox

static std::shared_ptr<S4U_PendingCommunication> igetMessage(simgrid::s4u::Mailbox *mailbox)

Asynchronously receive a message from a mailbox.

Parameters:

mailbox – the mailbox

Throws:

std::shared_ptr<NetworkError>

Returns:

a pending communication handle

static std::shared_ptr<S4U_PendingCommunication> iputMessage(simgrid::s4u::Mailbox *mailbox, SimulationMessage *msg)

Asynchronously send a message to a mailbox.

Parameters:
Throws:

std::shared_ptr<NetworkError>

Returns:

a pending communication handle

static void putMessage(simgrid::s4u::Mailbox *mailbox, SimulationMessage *m)

Synchronously send a message to a mailbox.

Parameters:
Throws:

std::shared_ptr<NetworkError>

static void retireTemporaryMailbox(simgrid::s4u::Mailbox *mailbox)

Retire a temporary mailbox.

Parameters:

mailbox – the mailbox to retire

Public Static Attributes

static unsigned long mailbox_pool_size

The mailbox pool size.

static simgrid::s4u::Mailbox *NULL_MAILBOX

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