SimGrid  3.21
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>

Inherits simgrid::s4u::Activity.

Public Member Functions

virtual ~Comm ()
 
Commstart () override
 Starts a previously created activity. More...
 
Commwait () override
 Tests whether the given activity is terminated yet. More...
 
Commwait_for (double timeout) override
 Blocks until the activity is terminated, or until the timeout is elapsed Raises: timeout exception. More...
 
bool test () override
 Returns whether this activity is completed. More...
 
Commdetach ()
 Start the comm, and ignore its result. More...
 
Commdetach (void(*clean_function)(void *))
 Start the comm, and ignore its result. More...
 
Commset_rate (double rate)
 Sets the maximal communication rate (in byte/sec). More...
 
Commset_src_data (void *buff)
 Specify the data to send. More...
 
Commset_src_data_size (size_t size)
 Specify the size of the data to send. More...
 
Commset_src_data (void *buff, size_t size)
 Specify the data to send and its size. More...
 
Commset_dst_data (void **buff)
 Specify where to receive the data. More...
 
Commset_dst_data (void **buff, size_t size)
 Specify the buffer in which the data should be received. More...
 
size_t get_dst_data_size ()
 Retrieve the size of the received data. More...
 
Commcancel () override
 Cancel that activity. More...
 
MailboxPtr get_mailbox ()
 Retrieve the mailbox on which this comm acts. More...
 
- Public Member Functions inherited from simgrid::s4u::Activity
void wait_until (double time_limit)
 Blocks until the activity is terminated, or until the time limit is reached Raises: timeout exception. More...
 
Activity::State get_state ()
 Retrieve the current state of the activity. More...
 
virtual double get_remaining ()
 Get the remaining amount of work that this Activity entails. More...
 
Activityset_remaining (double remains)
 Set the [remaining] amount of work that this Activity will entail. More...
 
Activityset_user_data (void *data)
 Put some user data onto the Activity. More...
 
void * get_user_data ()
 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 int test_any (std::vector< CommPtr > *comms)
 

Static Public Attributes

static simgrid::xbt::signal< void(simgrid::s4u::ActorPtr)> on_sender_start
 
static simgrid::xbt::signal< void(simgrid::s4u::ActorPtr)> on_receiver_start
 
static simgrid::xbt::signal< void(simgrid::s4u::ActorPtr)> on_completion
 

Friends

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

Additional Inherited Members

- Public Types inherited from simgrid::s4u::Activity
enum  State {
  State::INITED = 0, State::STARTED, State::CANCELED, State::ERRORED,
  State::FINISHED
}
 
- Protected Member Functions inherited from simgrid::s4u::Activity
 Activity ()=default
 
virtual ~Activity ()=default
 

Constructor & Destructor Documentation

◆ ~Comm()

virtual 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 
)
static

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)
static

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

◆ test_any()

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

take a vector s4u::CommPtr and return the rank of the first finished one (or -1 if none is done).

◆ start()

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

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

Tests whether the given activity is terminated yet.

This is a pure function. Blocks until the activity is terminated

Implements simgrid::s4u::Activity.

◆ wait_for()

Comm* simgrid::s4u::Comm::wait_for ( double  timeout)
overridevirtual

Blocks until the activity is terminated, or until the timeout is elapsed Raises: timeout exception.

Implements simgrid::s4u::Activity.

◆ test()

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

Returns whether this activity is completed.

Implements simgrid::s4u::Activity.

◆ detach() [1/2]

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

Start the comm, and ignore its result.

It can be completely forgotten after that.

◆ detach() [2/2]

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

Start the comm, and ignore its result.

It can be completely forgotten after that.

◆ set_rate()

Comm* simgrid::s4u::Comm::set_rate ( double  rate)

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

Must be done before start

◆ set_src_data() [1/2]

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

Specify the data to send.

This is way will get actually copied over to the receiver. That's completely unrelated from the simulated size (given with Activity::set_remaining()): you can send a short buffer in your simulator, that represents a very large message in the simulated world, or the opposite.

◆ set_src_data_size()

Comm* simgrid::s4u::Comm::set_src_data_size ( size_t  size)

Specify the size of the data to send.

Not to be mixed with Activity::set_remaining()

That's the size of the data to actually copy in the simulator (ie, the data passed with Activity::set_src_data()). That's completely unrelated from the simulated size (given with Activity::set_remaining()): you can send a short buffer in your simulator, that represents a very large message in the simulated world, or the opposite.

◆ set_src_data() [2/2]

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

Specify the data to send and its size.

Don't mix the size with Activity::set_remaining()

This is way will get actually copied over to the receiver. That's completely unrelated from the simulated size (given with Activity::set_remaining()): you can send a short buffer in your simulator, that represents a very large message in the simulated world, or the opposite.

◆ set_dst_data() [1/2]

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

Specify where to receive the data.

That's a buffer where the sent data will be copied

◆ set_dst_data() [2/2]

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

Specify the buffer in which the data should be received.

That's a buffer where the sent data will be copied

◆ get_dst_data_size()

size_t simgrid::s4u::Comm::get_dst_data_size ( )

Retrieve the size of the received data.

Not to be mixed with Activity::set_remaining()

◆ cancel()

Comm* simgrid::s4u::Comm::cancel ( )
overridevirtual

Cancel that activity.

Implements simgrid::s4u::Activity.

◆ get_mailbox()

MailboxPtr simgrid::s4u::Comm::get_mailbox ( )

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

◆ on_sender_start

simgrid::xbt::signal<void(simgrid::s4u::ActorPtr)> simgrid::s4u::Comm::on_sender_start
static

◆ on_receiver_start

simgrid::xbt::signal<void(simgrid::s4u::ActorPtr)> simgrid::s4u::Comm::on_receiver_start
static

◆ on_completion

simgrid::xbt::signal<void(simgrid::s4u::ActorPtr)> simgrid::s4u::Comm::on_completion
static

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