Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of https://framagit.org/simgrid/simgrid into CRTP
[simgrid.git] / src / s4u / s4u_Activity.cpp
1 /* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #include "xbt/log.h"
7
8 #include "simgrid/s4u/Activity.hpp"
9 #include "simgrid/s4u/Engine.hpp"
10
11 XBT_LOG_EXTERNAL_CATEGORY(s4u);
12 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_activity, s4u, "S4U activities");
13
14 namespace simgrid {
15 namespace s4u {
16
17 void Activity::wait_until(double time_limit)
18 {
19   double now = Engine::get_clock();
20   if (time_limit > now)
21     wait_for(time_limit - now);
22 }
23
24 double Activity::get_remaining()
25 {
26   return remains_;
27 }
28
29 Activity* Activity::set_remaining(double remains)
30 {
31   xbt_assert(state_ == State::INITED, "Cannot change the remaining amount of work once the Activity is started");
32   remains_ = remains;
33   return this;
34 }
35
36 } // namespace s4u
37 } // namespace simgrid