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
Update python/clusters-multicpu to the new API.
[simgrid.git]
/
include
/
simgrid
/
kernel
/
Timer.hpp
diff --git
a/include/simgrid/kernel/Timer.hpp
b/include/simgrid/kernel/Timer.hpp
index d5f1e15084ca38e33a63e526ee941a24d84b21e0..010a66f8fa3f4f8ccc11461873b01df7649ad405 100644
(file)
--- 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. */
/* 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,9
+12,7
@@
#include <boost/heap/fibonacci_heap.hpp>
#include <boost/heap/fibonacci_heap.hpp>
-namespace simgrid {
-namespace kernel {
-namespace timer {
+namespace simgrid::kernel::timer {
inline auto& kernel_timers() // avoid static initialization order fiasco
{
inline auto& kernel_timers() // avoid static initialization order fiasco
{
@@
-26,13
+23,15
@@
inline auto& kernel_timers() // avoid static initialization order fiasco
/** @brief Timer datatype */
class Timer {
/** @brief Timer datatype */
class Timer {
-public:
-
const double date
;
+ const double date_;
+
xbt::Task<void()> callback
;
std::remove_reference_t<decltype(kernel_timers())>::handle_type handle_;
std::remove_reference_t<decltype(kernel_timers())>::handle_type handle_;
- Timer(double date, xbt::Task<void()>&& callback) : date(date), callback(std::move(callback)) {}
+public:
+ double get_date() const { return date_; }
+
+ Timer(double date, xbt::Task<void()>&& callback) : date_(date), callback(std::move(callback)) {}
- xbt::Task<void()> callback;
void remove();
template <class F> static inline Timer* set(double date, F callback)
void remove();
template <class F> static inline Timer* set(double date, F callback)
@@
-42,10
+41,11
@@
public:
static Timer* set(double date, xbt::Task<void()>&& callback);
static double next() { return kernel_timers().empty() ? -1.0 : kernel_timers().top().first; }
static Timer* set(double date, xbt::Task<void()>&& 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_ */
#endif /* SRC_KERNEL_TIMER_TIMER_HPP_ */