libzed 1.9.9
A general-purpose library for quick and simple data manipulation.
 
Loading...
Searching...
No Matches
timeout.hpp
1#pragma once
2
3#include "timer.hpp"
4
5namespace z {
6namespace core {
13class timeout : public timer {
14private:
15 unsigned int timeout_goal;
16
17public:
28 timeout(unsigned int timeout_micros = -1, bool run = true) noexcept;
29
38
46
47#ifdef __has_include
48#if __has_include(<cereal/cereal.hpp>)
53 template <class Archive>
54 void save(Archive &ar) const {
56 int goal = timeout_goal;
59 }
60
65 template <class Archive>
66 void load(Archive &ar) {
68 int goal;
71 reset(std::chrono::high_resolution_clock::now() - std::chrono::microseconds(elapsed));
72 timeout_goal = goal;
73 }
74#endif
75#endif
76};
77} // namespace core
78} // namespace z
A wrapper for std::vector.
Definition array.hpp:72
A class for easily managing timing.
Definition timeout.hpp:13
void load(Archive &ar)
Serialization input.
Definition timeout.hpp:66
timeout(unsigned int timeout_micros=-1, bool run=true) noexcept
Timeout constructor.
bool timedOut() const noexcept
Check whether the timer has timed out.
void setTimeOut(unsigned int timeout_micros) noexcept
Set the time out goal.
void save(Archive &ar) const
Serialization output.
Definition timeout.hpp:54
A class for easily managing timers.
Definition timer.hpp:19
void reset() noexcept
Reset the timer.
unsigned int micros() const noexcept
Get the elapsed time in microseconds.