SimGrid  3.21
Versatile Simulation of Distributed Systems
simgrid::s4u::Activity Class Referenceabstract

Detailed Description

Activities.

This class is the ancestor of every activities that an actor can undertake. That is, activities are all the things that do take time to the actor in the simulated world.

They are somewhat linked but not identical to simgrid::kernel::resource::Action, that are stuff occurring on a resource:

  • A sequential execution activity encompasses 2 actions: one for the exec itself, and a time-limited sleep used as timeout detector.
  • A point-to-point communication activity encompasses 3 actions: one for the comm itself (which spans on all links of the path), and one infinite sleep used as failure detector on both sender and receiver hosts.
  • Synchronization activities may possibly be connected to no action.

#include <Activity.hpp>

Inherited by simgrid::s4u::Comm, simgrid::s4u::Exec, and simgrid::s4u::Io.

Public Types

enum  State {
  State::INITED = 0, State::STARTED, State::CANCELED, State::ERRORED,
  State::FINISHED
}
 

Public Member Functions

virtual Activitystart ()=0
 Starts a previously created activity. More...
 
virtual Activitywait ()=0
 Tests whether the given activity is terminated yet. More...
 
virtual Activitywait_for (double timeout)=0
 Blocks until the activity is terminated, or until the timeout is elapsed Raises: timeout exception. More...
 
void wait_until (double time_limit)
 Blocks until the activity is terminated, or until the time limit is reached Raises: timeout exception. More...
 
virtual Activitycancel ()=0
 Cancel that activity. More...
 
Activity::State get_state ()
 Retrieve the current state of the activity. More...
 
virtual bool test ()=0
 Returns whether this activity is completed. 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...
 

Protected Member Functions

 Activity ()=default
 
virtual ~Activity ()=default
 

Friends

void intrusive_ptr_release (Comm *c)
 
void intrusive_ptr_add_ref (Comm *c)
 
void intrusive_ptr_release (Exec *e)
 
void intrusive_ptr_add_ref (Exec *e)
 
void intrusive_ptr_release (Io *i)
 
void intrusive_ptr_add_ref (Io *i)
 

Member Enumeration Documentation

◆ State

Enumerator
INITED 
STARTED 
CANCELED 
ERRORED 
FINISHED 

Constructor & Destructor Documentation

◆ Activity()

simgrid::s4u::Activity::Activity ( )
protecteddefault

◆ ~Activity()

virtual simgrid::s4u::Activity::~Activity ( )
protectedvirtualdefault

Member Function Documentation

◆ start()

virtual Activity* simgrid::s4u::Activity::start ( )
pure virtual

Starts a previously created activity.

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

Implemented in simgrid::s4u::Comm, simgrid::s4u::Io, and simgrid::s4u::Exec.

◆ wait()

virtual Activity* simgrid::s4u::Activity::wait ( )
pure virtual

Tests whether the given activity is terminated yet.

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

Implemented in simgrid::s4u::Comm, simgrid::s4u::Io, and simgrid::s4u::Exec.

◆ wait_for()

virtual Activity* simgrid::s4u::Activity::wait_for ( double  timeout)
pure virtual

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

Implemented in simgrid::s4u::Comm, simgrid::s4u::Io, and simgrid::s4u::Exec.

◆ wait_until()

void simgrid::s4u::Activity::wait_until ( double  time_limit)

Blocks until the activity is terminated, or until the time limit is reached Raises: timeout exception.

◆ cancel()

virtual Activity* simgrid::s4u::Activity::cancel ( )
pure virtual

Cancel that activity.

Implemented in simgrid::s4u::Comm, simgrid::s4u::Io, and simgrid::s4u::Exec.

◆ get_state()

Activity::State simgrid::s4u::Activity::get_state ( )
inline

Retrieve the current state of the activity.

◆ test()

virtual bool simgrid::s4u::Activity::test ( )
pure virtual

Returns whether this activity is completed.

Implemented in simgrid::s4u::Comm, simgrid::s4u::Io, and simgrid::s4u::Exec.

◆ get_remaining()

virtual double simgrid::s4u::Activity::get_remaining ( )
virtual

Get the remaining amount of work that this Activity entails.

When it's 0, it's done.

Reimplemented in simgrid::s4u::Exec, and simgrid::s4u::Io.

◆ set_remaining()

Activity* simgrid::s4u::Activity::set_remaining ( double  remains)

Set the [remaining] amount of work that this Activity will entail.

It is forbidden to change the amount of work once the Activity is started

◆ set_user_data()

Activity* simgrid::s4u::Activity::set_user_data ( void *  data)
inline

Put some user data onto the Activity.

◆ get_user_data()

void* simgrid::s4u::Activity::get_user_data ( )
inline

Retrieve the user data of the Activity.

Friends And Related Function Documentation

◆ intrusive_ptr_release [1/3]

void intrusive_ptr_release ( Comm c)
friend

◆ intrusive_ptr_add_ref [1/3]

void intrusive_ptr_add_ref ( Comm c)
friend

◆ intrusive_ptr_release [2/3]

void intrusive_ptr_release ( Exec e)
friend

◆ intrusive_ptr_add_ref [2/3]

void intrusive_ptr_add_ref ( Exec e)
friend

◆ intrusive_ptr_release [3/3]

void intrusive_ptr_release ( Io i)
friend

◆ intrusive_ptr_add_ref [3/3]

void intrusive_ptr_add_ref ( Io i)
friend

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