diff options
author | Nick Mathewson <nickm@torproject.org> | 2010-06-25 15:31:46 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2010-06-25 15:31:46 -0400 |
commit | ad2d8ac073e576f538813a75183a3a8a477dfd5b (patch) | |
tree | 2b26c6794a1a25e0aae82ba33680ffe0fbddd2d6 /src/common/compat_libevent.h | |
parent | deb9e4aff7347860d5cb41426e4c02a4efc16253 (diff) | |
download | tor-ad2d8ac073e576f538813a75183a3a8a477dfd5b.tar.gz tor-ad2d8ac073e576f538813a75183a3a8a477dfd5b.zip |
Use Libevent 2.0's periodic timers where available.
These timers behave better with non-monotonic clocks than our old
ones, and also try harder to make once-per-second events get called
one second apart, rather than one-plus-epsilon seconds apart.
This fixes bug 943 for everybody using Libevent 2.0 or later.
Diffstat (limited to 'src/common/compat_libevent.h')
-rw-r--r-- | src/common/compat_libevent.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/common/compat_libevent.h b/src/common/compat_libevent.h index eedd9da43d..fdf5e0a18f 100644 --- a/src/common/compat_libevent.h +++ b/src/common/compat_libevent.h @@ -38,8 +38,14 @@ void tor_event_free(struct event *ev); #define tor_evdns_add_server_port evdns_add_server_port #endif -/* XXXX022 If we can drop support for Libevent before 1.1, we can - * do without this wrapper. */ +typedef struct periodic_timer_t periodic_timer_t; + +periodic_timer_t *periodic_timer_new(struct event_base *base, + const struct timeval *tv, + void (*cb)(periodic_timer_t *timer, void *data), + void *data); +void periodic_timer_free(periodic_timer_t *); + #ifdef HAVE_EVENT_BASE_LOOPEXIT #define tor_event_base_loopexit event_base_loopexit #else |