A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[s4u] More support for C++-style time and durations
[simgrid.git]
/
include
/
simgrid
/
s4u
/
actor.hpp
diff --git
a/include/simgrid/s4u/actor.hpp
b/include/simgrid/s4u/actor.hpp
index
8e1b703
..
5039f84
100644
(file)
--- a/
include/simgrid/s4u/actor.hpp
+++ b/
include/simgrid/s4u/actor.hpp
@@
-7,6
+7,7
@@
#define SIMGRID_S4U_ACTOR_HPP
#include <atomic>
#define SIMGRID_S4U_ACTOR_HPP
#include <atomic>
+#include <chrono>
#include <functional>
#include <memory>
#include <stdexcept>
#include <functional>
#include <memory>
#include <stdexcept>
@@
-20,6
+21,7
@@
#include <xbt/base.h>
#include <xbt/functional.hpp>
#include <xbt/base.h>
#include <xbt/functional.hpp>
+#include <simgrid/chrono.hpp>
#include <simgrid/simix.h>
#include <simgrid/s4u/forward.hpp>
#include <simgrid/simix.h>
#include <simgrid/s4u/forward.hpp>
@@
-258,6
+260,13
@@
namespace this_actor {
/** Block the actor sleeping for that amount of seconds (may throws hostFailure) */
XBT_PUBLIC(void) sleep(double duration);
/** Block the actor sleeping for that amount of seconds (may throws hostFailure) */
XBT_PUBLIC(void) sleep(double duration);
+ template<class Rep, class Period>
+ inline void sleep(std::chrono::duration<Rep, Period> duration)
+ {
+ auto seconds = std::chrono::duration_cast<SimulationClockDuration>(duration);
+ sleep(seconds.count());
+ }
+
/** Block the actor, computing the given amount of flops */
XBT_PUBLIC(e_smx_state_t) execute(double flop);
/** Block the actor, computing the given amount of flops */
XBT_PUBLIC(e_smx_state_t) execute(double flop);