SimGrid  3.18
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 ()
 
 XBT_ATTRIB_DEPRECATED_v320 ("Use Mailbox::put_init(): v3.20 will turn this warning into an error.") static CommPtr send_init(MailboxPtr dest)
 Creates (but don't start) an async send to the mailbox dest. More...
 
 XBT_ATTRIB_DEPRECATED_v320 ("Use Mailbox::put_init(): v3.20 will turn this warning into an error.") static CommPtr send_init(MailboxPtr dest
 Creates (but don't start) an async send to the mailbox dest. More...
 
 XBT_ATTRIB_DEPRECATED_v320 ("Use Mailbox::put_async(): v3.20 will turn this warning into an error.") static CommPtr send_async(MailboxPtr dest
 Creates and start an async send to the mailbox dest. More...
 
 XBT_ATTRIB_DEPRECATED_v320 ("Use Mailbox::get_init(): v3.20 will turn this warning into an error.") static CommPtr recv_init(MailboxPtr from)
 Creates (but don't start) an async recv onto the mailbox from. More...
 
 XBT_ATTRIB_DEPRECATED_v320 ("Use Mailbox::get_async(): v3.20 will turn this warning into an error.") static CommPtr recv_async(MailboxPtr from
 Creates and start an async recv to the mailbox from. More...
 
Activitystart () override
 Starts a previously created activity. More...
 
Activitywait () override
 Block the calling actor until the communication is finished. More...
 
Activitywait (double timeout) override
 Block the calling actor until the communication is finished, or until timeout. More...
 
Activitydetach ()
 Start the comm, and ignore its result. More...
 
Activitydetach (void(*cleanFunction)(void *))
 Start the comm, and ignore its result. More...
 
ActivitysetRate (double rate)
 Sets the maximal communication rate (in byte/sec). More...
 
ActivitysetSrcData (void *buff)
 Specify the data to send. More...
 
ActivitysetSrcDataSize (size_t size)
 Specify the size of the data to send. More...
 
ActivitysetSrcData (void *buff, size_t size)
 Specify the data to send and its size. More...
 
ActivitysetDstData (void **buff)
 Specify where to receive the data. More...
 
ActivitysetDstData (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 ()
 
Activitycancel ()
 
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...
 
virtual double getRemains ()
 Get the remaining amount of work that this Activity entails. More...
 
ActivitysetRemains (double remains)
 Set the [remaining] amount of work that this Activity will entail. More...
 
ActivitysetUserData (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)
 

Public Attributes

friend Mailbox
 
voiddata
 
void int simulatedByteAmount
 
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.

Examples:
examples/s4u/app-chainsend/s4u-app-chainsend.cpp, and examples/s4u/async-waitany/s4u-async-waitany.cpp.

◆ 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

◆ XBT_ATTRIB_DEPRECATED_v320() [1/5]

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

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

◆ XBT_ATTRIB_DEPRECATED_v320() [2/5]

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

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

◆ XBT_ATTRIB_DEPRECATED_v320() [3/5]

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

Creates and start an async send to the mailbox dest.

◆ XBT_ATTRIB_DEPRECATED_v320() [4/5]

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

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

◆ XBT_ATTRIB_DEPRECATED_v320() [5/5]

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

Creates and start an async recv to the mailbox from.

◆ start()

Activity * 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]

Activity * simgrid::s4u::Comm::wait ( )
overridevirtual

Block the calling actor until the communication is finished.

Implements simgrid::s4u::Activity.

◆ wait() [2/2]

Activity * 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]

Activity * simgrid::s4u::Comm::detach ( )

Start the comm, and ignore its result.

It can be completely forgotten after that.

◆ detach() [2/2]

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

Start the comm, and ignore its result.

It can be completely forgotten after that.

◆ setRate()

Activity * simgrid::s4u::Comm::setRate ( double  rate)

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

Must be done before start

◆ setSrcData() [1/2]

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

Specify the data to send.

◆ setSrcDataSize()

Activity * simgrid::s4u::Comm::setSrcDataSize ( size_t  size)

Specify the size of the data to send.

◆ setSrcData() [2/2]

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

Specify the data to send and its size.

◆ setDstData() [1/2]

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

Specify where to receive the data.

◆ setDstData() [2/2]

Activity * 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()

Activity * 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]

void * simgrid::s4u::Comm::data

◆ simulatedByteAmount

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

◆ data [2/2]

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

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