From ddd69d391e05356113aa62c26c9090f540c85b9d Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 17 Apr 2012 13:04:02 -0400 Subject: [PATCH] EVENT_BASE_FLAG_PRECISE_TIMER indicates we want fine timer precision There are a bunch of backends that can give us a reasonably good monotonic timer quickly, or a very precise monotonic timer less quickly. For example, Linux has CLOCK_MONOTONIC_COARSE (1msec precision), which is over twice as fast as CLOCK_MONOTONIC. Since epoll only lets you wait with 1msec precision, CLOCK_MONOTONIC_COARSE is a clear win. On Windows, you've got GetTickCount{,64}() which is fast, and QueryPerformanceCounter, which is precise but slow. Note that even in the cases where the underlying timer claims to have nanosecond resolution, we're still not exposing that via Libevent. Note also that "Precision" isn't the same as "Resolution" or "Accuracy". A timer's precision is the smallest change that the clock will register; a timer's resolution is the fineness of its underlying representation; a timer's accuracy is how much it drifts with respect to "Real Time", whatever that means. (Terms and definitions from PEP 418.) --- include/event2/event.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/event2/event.h b/include/event2/event.h index 9685e0a2..f1331f62 100644 --- a/include/event2/event.h +++ b/include/event2/event.h @@ -481,7 +481,14 @@ enum event_base_config_flag { This flag has no effect if you wind up using a backend other than epoll. */ - EVENT_BASE_FLAG_EPOLL_USE_CHANGELIST = 0x10 + EVENT_BASE_FLAG_EPOLL_USE_CHANGELIST = 0x10, + + /** Ordinarily, Libevent implements its time and timeout code using + the fastest monotonic timer that we have. If this flag is set, + however, we use less efficient more precise timer, assuming one is + present. + */ + EVENT_BASE_FLAG_PRECISE_TIMER = 0x20 }; /**