-inline auto& simix_timers() // avoid static initialization order fiasco
-{
- using TimerQelt = std::pair<double, Timer*>;
- static boost::heap::fibonacci_heap<TimerQelt, boost::heap::compare<xbt::HeapComparator<TimerQelt>>> value;
- return value;
-}
-
-/** @brief Timer datatype */
-class Timer {
- double date = 0.0;
-
-public:
- std::remove_reference_t<decltype(simix_timers())>::handle_type handle_;
-
- Timer(double date, simgrid::xbt::Task<void()>&& callback) : date(date), callback(std::move(callback)) {}
-
- simgrid::xbt::Task<void()> callback;
- double get_date() const { return date; }
- void remove();
-
- template <class F> static inline Timer* set(double date, F callback)
- {
- return set(date, simgrid::xbt::Task<void()>(std::move(callback)));
- }