* That is, activities are all the things that do take time to the actor in the simulated world.
*/
class XBT_PUBLIC Activity : public xbt::Extendable<Activity> {
+#ifndef DOXYGEN
friend Comm;
friend Exec;
friend Io;
-#ifndef DOXYGEN
+ friend kernel::activity::ActivityImpl;
friend std::vector<ActivityPtr> create_DAG_from_dot(const std::string& filename);
friend std::vector<ActivityPtr> create_DAG_from_DAX(const std::string& filename);
#endif
private:
static xbt::signal<void(Activity&)> on_veto;
- static xbt::signal<void(Activity&)> on_completion;
+ static xbt::signal<void(Activity const&)> on_completion;
+ static xbt::signal<void(Activity const&)> on_suspended;
+ static xbt::signal<void(Activity const&)> on_resumed;
public:
/*! Add a callback fired each time that the activity fails to start because of a veto (e.g., unsolved dependency or no
static void on_veto_cb(const std::function<void(Activity&)>& cb) { on_veto.connect(cb); }
/*! Add a callback fired when the activity completes (either normally, cancelled or failed) */
static void on_completion_cb(const std::function<void(Activity const&)>& cb) { on_completion.connect(cb); }
+ /*! Add a callback fired when the activity is suspended */
+ static void on_suspended_cb(const std::function<void(Activity const&)>& cb) { on_suspended.connect(cb); }
+ /*! Add a callback fired when the activity is resumed after being suspended */
+ static void on_resumed_cb(const std::function<void(Activity const&)>& cb) { on_resumed.connect(cb); }
void vetoable_start()
{
* This function is optional: you can call wait() even if you didn't call start()
*/
virtual Activity* start() = 0;
- /** Blocks the current actor until the activity is terminated */
/** Tests whether the given activity is terminated yet. */
virtual bool test();
/*! take a vector s4u::ActivityPtr and return the rank of the first finished one (or -1 if none is done). */
static ssize_t test_any(const std::vector<ActivityPtr>& activities);
+ /** Blocks the current actor until the activity is terminated */
Activity* wait() { return wait_for(-1.0); }
/** Blocks the current actor until the activity is terminated, or until the timeout is elapsed\n
* Raises: timeout exception.*/
}
AnyActivity* set_name(const std::string& name)
{
- xbt_assert(get_state() == State::INITED, "Cannot change the name of an activity after its start");
name_ = name;
return static_cast<AnyActivity*>(this);
}