Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines with new year.
[simgrid.git] / src / s4u / s4u_Activity.cpp
index d3eaaef..374eaea 100644 (file)
@@ -1,13 +1,12 @@
-/* Copyright (c) 2006-2018. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#include "xbt/asserts.h"
 #include "xbt/log.h"
 
 #include "simgrid/s4u/Activity.hpp"
+#include "simgrid/s4u/Engine.hpp"
 
 XBT_LOG_EXTERNAL_CATEGORY(s4u);
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_activity, s4u, "S4U activities");
@@ -15,6 +14,13 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_activity, s4u, "S4U activities");
 namespace simgrid {
 namespace s4u {
 
+void Activity::wait_until(double time_limit)
+{
+  double now = Engine::get_clock();
+  if (time_limit > now)
+    wait_for(time_limit - now);
+}
+
 double Activity::get_remaining()
 {
   return remains_;
@@ -22,7 +28,7 @@ double Activity::get_remaining()
 
 Activity* Activity::set_remaining(double remains)
 {
-  xbt_assert(state_ == State::inited, "Cannot change the remaining amount of work once the Activity is started");
+  xbt_assert(state_ == State::INITED, "Cannot change the remaining amount of work once the Activity is started");
   remains_ = remains;
   return this;
 }