23 #ifndef GUL14_TIME_UTIL_H_
24 #define GUL14_TIME_UTIL_H_
54 inline std::chrono::steady_clock::time_point
tic()
56 return std::chrono::steady_clock::now();
91 template<
class TimeUnitType = std::chrono::duration<
double>>
92 auto toc(std::chrono::steady_clock::time_point t0)
94 return std::chrono::duration_cast<TimeUnitType>(
tic() - t0).count();
113 template<
class Rep,
class Period >
114 bool sleep(
const std::chrono::duration<Rep, Period>& duration,
const Trigger& trg)
137 return sleep(std::chrono::duration<double>{ seconds }, trg);
158 template<
class Rep,
class Period >
159 bool sleep(
const std::chrono::duration<Rep, Period>& duration)
161 std::this_thread::sleep_for(duration);
184 return sleep(std::chrono::duration<double>{ seconds });
Declaration of the Trigger class for the General Utility Library.
A class that allows sending triggers and waiting for them across different threads.
Definition: Trigger.h:111
bool wait_for(const std::chrono::duration< Rep, Period > &delta_t) const
Suspend execution of the current thread until the trigger goes high (true) or at least the given time...
Definition: Trigger.h:189
auto toc(std::chrono::steady_clock::time_point t0)
Return the elapsed time in seconds (or a different unit) since the given time point.
Definition: time_util.h:92
bool sleep(const std::chrono::duration< Rep, Period > &duration, const Trigger &trg)
Sleep for at least the given time span, with the option of being woken up from another thread.
Definition: time_util.h:114
std::chrono::steady_clock::time_point tic()
Return the current time as a std::chrono time_point.
Definition: time_util.h:54
Definition of macros used internally by GUL.
Namespace gul14 contains all functions and classes of the General Utility Library.
Definition: doxygen.h:26