17 #include <unordered_map>
37 std::function<void()>
function;
48 explicit Timeout(
int max_tmos = 100);
60 void add_periodic(
const char* desc,
void* tag, std::function<
void()>&
function
62 , uint64_t start_us = 0);
73 void add_periodic(
const char* desc,
void* tag, std::function<
void()>&
function
86 , uint64_t start_us = 0);
97 void add_relative(
const char* desc,
void* tag, std::function<
void()>&
function
115 void copy_in_timeout(
const char* desc, uint64_t period_us, uint64_t start_us = 0);
135 , uint64_t* tmo_tod_us);
162 std::mutex lock_mutex_;
163 std::vector<timeoutspec> tmospecs_;
164 std::list<size_t> free_;
165 std::multimap<uint64_t, size_t> active_time_;
166 std::unordered_multimap<std::string, size_t> active_desc_;
168 void timeoutlist_init();
171 ,
const timespec& ts);
173 int get_clear_next_expired_timeout(
timeoutspec& tmo
174 , uint64_t tod_now_us);
void copy_in_timeout(const char *desc, uint64_t period_us, uint64_t start_us=0)
Add a timeout with the given parameters.
void add_relative(const char *desc, void *tag, std::function< void()> &function, int rel_ms)
Add a periodic timeout to the Timeout container.
void * tag
could be file descriptor (fd)
uint64_t tmo_tod_us
When the function should be executed (gettimeofday, microseconds)
The Timeout class performs registered actions at specified intervals.
int get_next_timeout_msdly()
Get the amount to wait for the next timeout to occur.
int check
Check the timeoutspec.
int missed_periods
Number of periods that passed while the function was executing.
void get_next_timeout_delay(int64_t *delay_us)
Get the amount to wait for the next timeout to occur.
uint64_t period_us
0 if not periodic
Specification for a Timeout function.
int get_next_expired_timeout(std::string &desc, void **tag, std::function< void()> &function, uint64_t *tmo_tod_us)
Get a timeout that has expired.
bool is_consistent()
Run a consistency check on all confiugured timeouts.
std::string desc
Description of the Timeout function.
bool cancel_timeout(void *tag, std::string desc)
Cancel the timeout having the given description and tag.
void add_periodic(const char *desc, void *tag, std::function< void()> &function, uint64_t period_us, uint64_t start_us=0)
Add a periodic timeout to the Timeout container.
Timeout(int max_tmos=100)
Construct a Timeout object.
void list_active_time()
TRACE all active timeouts.