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
15 #include <simgrid/s4u/forward.hpp>
16 #include <simgrid/forward.h>
19 inited, started, finished
20 } e_s4u_activity_state_t;
27 * 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.
29 XBT_PUBLIC_CLASS Activity {
36 /** Starts a previously created activity.
38 * This function is optional: you can call wait() even if you didn't call start()
40 virtual void start()=0;
41 /** Tests whether the given activity is terminated yet. This is a pure function. */
42 //virtual bool test()=0;
43 /** Blocks until the activity is terminated */
44 virtual void wait()=0;
45 /** Blocks until the activity is terminated, or until the timeout is elapsed
46 * Raises: timeout exception.*/
47 virtual void wait(double timeout)=0;
48 /** Cancel that activity */
49 //virtual void cancel();
50 /** Retrieve the current state of the activity */
51 e_s4u_activity_state_t getState() {return state_;}
53 /** Get the remaining amount of work that this Activity entails. When it's 0, it's done. */
55 /** Set the [remaining] amount of work that this Activity will entail
57 * It is forbidden to change the amount of work once the Activity is started */
58 void setRemains(double remains);
60 /** Put some user data onto the Activity */
61 void setUserData(void *data) {userData_=data;}
62 /** Retrieve the user data of the Activity */
63 void *getUserData() { return userData_; }
66 simgrid::simix::Synchro *pimpl_ = nullptr;
67 e_s4u_activity_state_t state_ = inited;
69 void *userData_ = nullptr;
72 }}; // Namespace simgrid::s4u
74 #endif /* SIMGRID_S4U_ACTIVITY_HPP */