X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/322e28c4503ed99d6c36ad9f450a3c0e515b4a8d..40ee10e13b61bfb28374d96ade010a262b5abd44:/include/simgrid/kernel/Timer.hpp diff --git a/include/simgrid/kernel/Timer.hpp b/include/simgrid/kernel/Timer.hpp index d9af16420a..010a66f8fa 100644 --- a/include/simgrid/kernel/Timer.hpp +++ b/include/simgrid/kernel/Timer.hpp @@ -1,5 +1,4 @@ -/* Copyright (c) 2021. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2021-2023. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -13,13 +12,11 @@ #include -namespace simgrid { -namespace kernel { -namespace timer { +namespace simgrid::kernel::timer { inline auto& kernel_timers() // avoid static initialization order fiasco { - using TimerQelt = std::pair>; + using TimerQelt = std::pair; static boost::heap::fibonacci_heap>> value; return value; } @@ -33,25 +30,22 @@ class Timer { public: double get_date() const { return date_; } - Timer(double date, xbt::Task&& callback) : date_(date), callback(std::move(callback)) {} void remove(); - template static inline std::shared_ptr set(double date, F callback) + template static inline Timer* set(double date, F callback) { return set(date, xbt::Task(std::move(callback))); } - static std::shared_ptr set(double date, xbt::Task&& callback); + static Timer* set(double date, xbt::Task&& callback); static double next() { return kernel_timers().empty() ? -1.0 : kernel_timers().top().first; } /** Handle any pending timer. Returns if something was actually run. */ static bool execute_all(); }; -} // namespace timer -} // namespace kernel -} // namespace simgrid +} // namespace simgrid::kernel::timer #endif /* SRC_KERNEL_TIMER_TIMER_HPP_ */