Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[codacy/cppcheck] Reduce scope for variables.
[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/asserts.h"
7 #include "xbt/log.h"
8
9 #include "simgrid/s4u/Activity.hpp"
10 #include "simgrid/s4u/Engine.hpp"
11
12 XBT_LOG_EXTERNAL_CATEGORY(s4u);
13 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_activity, s4u, "S4U activities");
14
15 namespace simgrid {
16 namespace s4u {
17
18 void Activity::wait_until(double time_limit)
19 {
20   double now = Engine::get_clock();
21   if (time_limit > now)
22     wait_for(time_limit - now);
23 }
24
25 double Activity::get_remaining()
26 {
27   return remains_;
28 }
29
30 Activity* Activity::set_remaining(double remains)
31 {
32   xbt_assert(state_ == State::INITED, "Cannot change the remaining amount of work once the Activity is started");
33   remains_ = remains;
34   return this;
35 }
36
37 } // namespace s4u
38 } // namespace simgrid