| 1 |
#ifndef _TIMER_POSIX_H_ |
| 2 |
#define _TIMER_POSIX_H_ |
| 3 |
|
| 4 |
#ifndef _WIN32 |
| 5 |
|
| 6 |
#include <functional> |
| 7 |
#include "timestamp.h" |
| 8 |
#include "threadutils.h" |
| 9 |
#include "optional.h" |
| 10 |
|
| 11 |
class Timer { |
| 12 |
std::function<void ()> callback; |
| 13 |
Mutex mutex; |
| 14 |
ConditionVariable cond; |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
Optional<tct_thrd_t> bgthread; |
| 19 |
Optional<Timestamp> wakeAt; |
| 20 |
bool stopped; |
| 21 |
|
| 22 |
static int bg_main_func(void*); |
| 23 |
void bg_main(); |
| 24 |
public: |
| 25 |
Timer(const std::function<void ()>& callback); |
| 26 |
virtual ~Timer(); |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
void set(const Timestamp& timestamp); |
| 33 |
}; |
| 34 |
|
| 35 |
|
| 36 |
#endif |
| 37 |
|
| 38 |
#endif |