1 /* Copyright (c) 2006-2015. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #ifndef SIMGRID_S4U_ACTIVITY_HPP
8 #define SIMGRID_S4U_ACTIVITY_HPP
14 #include <simgrid/s4u/forward.hpp>
15 #include "simgrid/forward.h"
19 inited, started, finished
20 } e_s4u_activity_state_t;
28 * This class is the ancestor of every activities that an actor can undertake, that is, of the actions that do take time in the simulated world.
30 XBT_PUBLIC_CLASS Activity {
37 simgrid::simix::Synchro *pimpl_ = NULL;
40 e_s4u_activity_state_t state_ = inited;
42 /** Starts a previously created activity.
44 * This function is optional: you can call wait() even if you didn't call start()
46 virtual void start()=0;
47 /** Tests whether the given activity is terminated yet. This is a pure function. */
48 //virtual bool test()=0;
49 /** Blocks until the activity is terminated */
50 virtual void wait()=0;
51 /** Blocks until the activity is terminated, or until the timeout is elapsed
52 * Raises: timeout exception.*/
53 virtual void wait(double timeout)=0;
54 /** Cancel that activity */
55 //virtual void cancel();
56 /** Retrieve the current state of the activity */
57 e_s4u_activity_state_t getState() {return state_;}
62 /** Get the remaining amount of work that this Activity entails. When it's 0, it's done. */
64 /** Set the [remaining] amount of work that this Activity will entail
66 * It is forbidden to change the amount of work once the Activity is started */
67 void setRemains(double remains);
70 void *userData_ = NULL;
72 /** Put some user data onto the Activity */
73 void setUserData(void *data) {userData_=data;}
74 /** Retrieve the user data of the Activity */
75 void *getUserData() { return userData_; }
78 }}; // Namespace simgrid::s4u
80 #endif /* SIMGRID_S4U_ACTIVITY_HPP */