For consistency avec ConditionVariable and the C++ standard library.
simgrid::s4u::Actor::createActor("worker", simgrid::s4u::Host::by_name("Tremblay"), worker, mutex, std::ref(result));
}
simgrid::s4u::Actor::createActor("worker", simgrid::s4u::Host::by_name("Tremblay"), worker, mutex, std::ref(result));
}
- simgrid::s4u::this_actor::sleep(10);
+ simgrid::s4u::this_actor::sleep_for(10);
XBT_INFO("Results is -> %d", result);
}
XBT_INFO("Results is -> %d", result);
}
namespace this_actor {
/** Block the actor sleeping for that amount of seconds (may throws hostFailure) */
namespace this_actor {
/** Block the actor sleeping for that amount of seconds (may throws hostFailure) */
- XBT_PUBLIC(void) sleep(double duration);
+ XBT_PUBLIC(void) sleep_for(double duration);
+ XBT_PUBLIC(void) sleep_until(double timeout);
template<class Rep, class Period>
template<class Rep, class Period>
- inline void sleep(std::chrono::duration<Rep, Period> duration)
+ inline void sleep_for(std::chrono::duration<Rep, Period> duration)
{
auto seconds = std::chrono::duration_cast<SimulationClockDuration>(duration);
{
auto seconds = std::chrono::duration_cast<SimulationClockDuration>(duration);
- sleep(seconds.count());
+ this_actor::sleep_for(seconds.count());
+ }
+ template<class Duration>
+ inline void sleep_until(const SimulationTimePoint<Duration>& timeout_time)
+ {
+ auto timeout_native = std::chrono::time_point_cast<SimulationClockDuration>(timeout_time);
+ this_actor::sleep_until(timeout_native.time_since_epoch().count());
+ }
+
+ XBT_ATTRIB_DEPRECATED("Use sleep_for()")
+ inline void sleep(double duration)
+ {
+ return sleep_for(duration);
}
/** Block the actor, computing the given amount of flops */
}
/** Block the actor, computing the given amount of flops */
-Session* Session::spawnvp(const char *path, char *const argv[])
+Session* Session::spawnvp(const char *file, char *const argv[])
{
return Session::fork([&] {
{
return Session::fork([&] {
-void sleep(double duration) {
- simcall_process_sleep(duration);
+void sleep_for(double duration)
+{
+ if (duration > 0)
+ simcall_process_sleep(duration);
+}
+
+XBT_PUBLIC(void) sleep_until(double timeout)
+{
+ double now = SIMIX_get_clock();
+ if (timeout > now)
+ simcall_process_sleep(timeout - now);
}
e_smx_state_t execute(double flops) {
}
e_smx_state_t execute(double flops) {