-
Notifications
You must be signed in to change notification settings - Fork 40
/
timer.cpp
52 lines (39 loc) · 1.07 KB
/
timer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright (c) 2013 Arista Networks, Inc. All rights reserved.
// Arista Networks, Inc. Confidential and Proprietary.
#include <time.h>
#include <cstdio>
#include "eos/base_mgr.h"
#include "eos/panic.h"
#include "eos/timer.h"
#include "impl.h"
namespace eos {
//static seconds_t const TIME_BASE = 1000000.0;
seconds_t now() {
struct timespec t;
int ret = clock_gettime(CLOCK_MONOTONIC, &t);
if(ret == -1) {
panic("clock_gettime(CLOCK_MONOTONIC) returned %d", ret);
}
return t.tv_sec + 0.000000001 * t.tv_nsec;// + TIME_BASE;
}
timeout_handler::timeout_handler(timeout_mgr * mgr) :
base_handler<timeout_mgr, timeout_handler>(mgr) {
impl.register_timeout_handler(this);
}
timeout_handler::~timeout_handler() {
impl.unregister_timeout_handler(this);
}
void
timeout_handler::timeout_time_is(seconds_t timeout) {
impl.timeout_is(this, timeout);
}
class timeout_mgr_impl: public timeout_mgr {
public:
timeout_mgr_impl() {
}
void init_handler(timeout_handler * handler) {
// TODO: No op impl.
}
};
DEFINE_STUB_MGR_CTOR(timeout_mgr)
}