void sleep_for(double duration)
{
xbt_assert(std::isfinite(duration), "duration is not finite!");
+ static unsigned int warned = 0; // At most 20 such warnings
+
+ if (duration <= 0) /* that's a no-op */
+ return;
+
+ if (duration < sg_surf_precision) {
+ warned++;
+ if (warned <= 20)
+ XBT_INFO("The parameter to sleep_for() is smaller than the SimGrid numerical accuracy (%g < %g). "
+ "Please refer to https://simgrid.org/doc/latest/Configuring_SimGrid.html#numerical-precision",
+ duration, sg_surf_precision);
+ if (warned == 20)
+ XBT_VERB("(further warnings about the numerical accuracy of sleep_for() will be omitted).");
+ }
- if (duration > 0) {
- kernel::actor::ActorImpl* issuer = kernel::actor::ActorImpl::self();
- Actor::on_sleep(*issuer->get_ciface());
-
- kernel::actor::simcall_blocking([issuer, duration]() {
- if (MC_is_active() || MC_record_replay_is_active()) {
- MC_process_clock_add(issuer, duration);
- issuer->simcall_answer();
- return;
- }
- kernel::activity::ActivityImplPtr sync = issuer->sleep(duration);
- sync->register_simcall(&issuer->simcall_);
- });
+ kernel::actor::ActorImpl* issuer = kernel::actor::ActorImpl::self();
+ Actor::on_sleep(*issuer->get_ciface());
- Actor::on_wake_up(*issuer->get_ciface());
- }
+ kernel::actor::simcall_blocking([issuer, duration]() {
+ if (MC_is_active() || MC_record_replay_is_active()) {
+ MC_process_clock_add(issuer, duration);
+ issuer->simcall_answer();
+ return;
+ }
+ kernel::activity::ActivityImplPtr sync = issuer->sleep(duration);
+ sync->register_simcall(&issuer->simcall_);
+ });
+
+ Actor::on_wake_up(*issuer->get_ciface());
}
void yield()