SimGrid  3.17
Versatile Simulation of Distributed Systems
simgrid::s4u::Comm Class Reference

Detailed Description

Communication async.

Represents all asynchronous communications, that you can test or wait onto.

#include <Comm.hpp>

Inheritance diagram for simgrid::s4u::Comm:
simgrid::s4u::Activity

Public Member Functions

virtual ~Comm ()
 
void start () override
 Starts a previously created activity. More...
 
void wait () override
 Block the calling actor until the communication is finished. More...
 
void wait (double timeout) override
 Block the calling actor until the communication is finished, or until timeout. More...
 
void detach ()
 Start the comm, and ignore its result. More...
 
void detach (void(*cleanFunction)(void *))
 Start the comm, and ignore its result. More...
 
void setRate (double rate)
 Sets the maximal communication rate (in byte/sec). More...
 
void setSrcData (void *buff)
 Specify the data to send. More...
 
void setSrcDataSize (size_t size)
 Specify the size of the data to send. More...
 
void setSrcData (void *buff, size_t size)
 Specify the data to send and its size. More...
 
void setDstData (void **buff)
 Specify where to receive the data. More...
 
void setDstData (void **buff, size_t size)
 Specify the buffer in which the data should be received. More...
 
size_t getDstDataSize ()
 Retrieve the size of the received data. More...
 
bool test ()
 
void cancel ()
 
MailboxPtr getMailbox ()
 Retrieve the mailbox on which this comm acts. More...
 
- Public Member Functions inherited from simgrid::s4u::Activity
 Activity (Activity const &)=delete
 
Activityoperator= (Activity const &)=delete
 
e_s4u_activity_state_t getState ()
 Cancel that activity. More...
 
double getRemains ()
 Get the remaining amount of work that this Activity entails. More...
 
void setRemains (double remains)
 Set the [remaining] amount of work that this Activity will entail. More...
 
void setUserData (void *data)
 Put some user data onto the Activity. More...
 
voidgetUserData ()
 Retrieve the user data of the Activity. More...
 

Static Public Member Functions

static int wait_any (std::vector< CommPtr > *comms)
 
static int wait_any_for (std::vector< CommPtr > *comms_in, double timeout)
 
static void wait_all (std::vector< CommPtr > *comms)
 
static CommPtr XBT_ATTRIB_DEPRECATED_v320 ("Use Mailbox::put_init(): v3.20 will turn this warning into an error.") send_init(MailboxPtr dest)
 Creates (but don't start) an async send to the mailbox dest. More...
 
static CommPtr XBT_ATTRIB_DEPRECATED_v320 ("Use Mailbox::put_init(): v3.20 will turn this warning into an error.") send_init(MailboxPtr dest
 Creates (but don't start) an async send to the mailbox dest. More...
 
static CommPtr XBT_ATTRIB_DEPRECATED_v320 ("Use Mailbox::put_async(): v3.20 will turn this warning into an error.") send_async(MailboxPtr dest
 Creates and start an async send to the mailbox dest. More...
 
static CommPtr XBT_ATTRIB_DEPRECATED_v320 ("Use Mailbox::get_init(): v3.20 will turn this warning into an error.") recv_init(MailboxPtr from)
 Creates (but don't start) an async recv onto the mailbox from. More...
 
static CommPtr XBT_ATTRIB_DEPRECATED_v320 ("Use Mailbox::get_async(): v3.20 will turn this warning into an error.") recv_async(MailboxPtr from
 Creates and start an async recv to the mailbox from. More...
 

Public Attributes

friend Mailbox
 
static CommPtr voiddata
 
static CommPtr void int simulatedByteAmount
 
static CommPtr void ** data
 

Friends

void intrusive_ptr_release (simgrid::s4u::Comm *c)
 
void intrusive_ptr_add_ref (simgrid::s4u::Comm *c)
 

Additional Inherited Members

- Protected Member Functions inherited from simgrid::s4u::Activity
 Activity ()=default
 
virtual ~Activity ()=default
 

Constructor & Destructor Documentation

◆ ~Comm()

simgrid::s4u::Comm::~Comm ( )
virtual

Member Function Documentation

◆ wait_any()

static int simgrid::s4u::Comm::wait_any ( std::vector< CommPtr > *  comms)
inlinestatic

take a vector s4u::CommPtr and return when one of them is finished. The return value is the rank of the first finished CommPtr.

◆ wait_any_for()

static int simgrid::s4u::Comm::wait_any_for ( std::vector< CommPtr > *  comms_in,
double  timeout 
)
inlinestatic

Same as wait_any, but with a timeout. If the timeout occurs, parameter last is returned.

◆ wait_all()

static void simgrid::s4u::Comm::wait_all ( std::vector< CommPtr > *  comms)
inlinestatic

take a vector s4u::CommPtr and return when all of them is finished.

◆ XBT_ATTRIB_DEPRECATED_v320() [1/5]

static CommPtr simgrid::s4u::Comm::XBT_ATTRIB_DEPRECATED_v320 ( "Use Mailbox::put_init(): v3.20 will turn this warning into an error."  )
inlinestatic

Creates (but don't start) an async send to the mailbox dest.

◆ XBT_ATTRIB_DEPRECATED_v320() [2/5]

static CommPtr simgrid::s4u::Comm::XBT_ATTRIB_DEPRECATED_v320 ( "Use Mailbox::put_init(): v3.20 will turn this warning into an error."  )
static

Creates (but don't start) an async send to the mailbox dest.

◆ XBT_ATTRIB_DEPRECATED_v320() [3/5]

static CommPtr simgrid::s4u::Comm::XBT_ATTRIB_DEPRECATED_v320 ( "Use Mailbox::put_async(): v3.20 will turn this warning into an error."  )
static

Creates and start an async send to the mailbox dest.

◆ XBT_ATTRIB_DEPRECATED_v320() [4/5]

static CommPtr simgrid::s4u::Comm::XBT_ATTRIB_DEPRECATED_v320 ( "Use Mailbox::get_init(): v3.20 will turn this warning into an error."  )
inlinestatic

Creates (but don't start) an async recv onto the mailbox from.

◆ XBT_ATTRIB_DEPRECATED_v320() [5/5]

static CommPtr simgrid::s4u::Comm::XBT_ATTRIB_DEPRECATED_v320 ( "Use Mailbox::get_async(): v3.20 will turn this warning into an error."  )
static

Creates and start an async recv to the mailbox from.

◆ start()

void simgrid::s4u::Comm::start ( )
overridevirtual

Starts a previously created activity.

This function is optional: you can call wait() even if you didn't call start()

Implements simgrid::s4u::Activity.

◆ wait() [1/2]

void simgrid::s4u::Comm::wait ( )
overridevirtual

Block the calling actor until the communication is finished.

Implements simgrid::s4u::Activity.

◆ wait() [2/2]

void simgrid::s4u::Comm::wait ( double  timeout)
overridevirtual

Block the calling actor until the communication is finished, or until timeout.

On timeout, an exception is thrown.

Parameters
timeoutthe amount of seconds to wait for the comm termination. Negative values denote infinite wait times. 0 as a timeout returns immediately.

Implements simgrid::s4u::Activity.

◆ detach() [1/2]

void simgrid::s4u::Comm::detach ( )

Start the comm, and ignore its result.

It can be completely forgotten after that.

◆ detach() [2/2]

void simgrid::s4u::Comm::detach ( void(*)(void *)  cleanFunction)
inline

Start the comm, and ignore its result.

It can be completely forgotten after that.

◆ setRate()

void simgrid::s4u::Comm::setRate ( double  rate)

Sets the maximal communication rate (in byte/sec).

Must be done before start

◆ setSrcData() [1/2]

void simgrid::s4u::Comm::setSrcData ( void buff)

Specify the data to send.

◆ setSrcDataSize()

void simgrid::s4u::Comm::setSrcDataSize ( size_t  size)

Specify the size of the data to send.

◆ setSrcData() [2/2]

void simgrid::s4u::Comm::setSrcData ( void buff,
size_t  size 
)

Specify the data to send and its size.

◆ setDstData() [1/2]

void simgrid::s4u::Comm::setDstData ( void **  buff)

Specify where to receive the data.

◆ setDstData() [2/2]

void simgrid::s4u::Comm::setDstData ( void **  buff,
size_t  size 
)

Specify the buffer in which the data should be received.

◆ getDstDataSize()

size_t simgrid::s4u::Comm::getDstDataSize ( )

Retrieve the size of the received data.

◆ test()

bool simgrid::s4u::Comm::test ( )

◆ cancel()

void simgrid::s4u::Comm::cancel ( )

◆ getMailbox()

MailboxPtr simgrid::s4u::Comm::getMailbox ( )

Retrieve the mailbox on which this comm acts.

Friends And Related Function Documentation

◆ intrusive_ptr_release

void intrusive_ptr_release ( simgrid::s4u::Comm c)
friend

◆ intrusive_ptr_add_ref

void intrusive_ptr_add_ref ( simgrid::s4u::Comm c)
friend

Member Data Documentation

◆ Mailbox

friend simgrid::s4u::Comm::Mailbox

◆ data [1/2]

static CommPtr void * simgrid::s4u::Comm::data

◆ simulatedByteAmount

static CommPtr void int simgrid::s4u::Comm::simulatedByteAmount
Initial value:
{
return dest->put_init(data, simulatedByteAmount)

◆ data [2/2]

CommPtr void** simgrid::s4u::Comm::data
Initial value:
{
return from->get_async(data)

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