From f5e4eb05e5bdf61b0a1b11f99effaf835a8796ce Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 20 Apr 2012 13:14:10 -0400 Subject: Refactor monotonic timer handling into a new type and set of functions; add a gettimeofday-based ratcheting implementation Now, event.c can always assume that we have a monotonic timer; this makes event.c easier to write. --- event-internal.h | 36 ++---------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) (limited to 'event-internal.h') diff --git a/event-internal.h b/event-internal.h index a2fc8e80..e54038c5 100644 --- a/event-internal.h +++ b/event-internal.h @@ -36,10 +36,6 @@ extern "C" { #include #include -#ifdef EVENT__HAVE_MACH_MACH_TIME_H -/* For mach_timebase_info */ -#include -#endif #include "event2/event_struct.h" #include "minheap-internal.h" #include "evsignal-internal.h" @@ -62,16 +58,6 @@ extern "C" { #define EV_CLOSURE_SIGNAL 1 #define EV_CLOSURE_PERSIST 2 -/* Define HAVE_ANY_MONOTONIC iff we *might* have a working monotonic - * clock implementation */ -#if defined(EVENT__HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC) -#define HAVE_ANY_MONOTONIC 1 -#elif defined(EVENT__HAVE_MACH_ABSOLUTE_TIME) -#define HAVE_ANY_MONOTONIC 1 -#elif defined(_WIN32) -#define HAVE_ANY_MONOTONIC 1 -#endif - /** Structure to define the backend of a given event_base. */ struct eventop { /** The name of this backend. */ @@ -247,9 +233,6 @@ struct event_base { /** Mapping from signal numbers to enabled (added) events. */ struct event_signal_map sigmap; - /** Stored timeval; used to detect when time is running backwards. */ - struct timeval event_tv; - /** Priority queue of events with timeouts. */ struct min_heap timeheap; @@ -257,27 +240,13 @@ struct event_base { * too often. */ struct timeval tv_cache; -#if defined(EVENT__HAVE_MACH_ABSOLUTE_TIME) - struct mach_timebase_info mach_timebase_units; -#endif -#if defined(EVENT__HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC) && defined(CLOCK_MONOTONIC_COARSE) -#define CLOCK_IS_SELECTED - int monotonic_clock; -#endif -#ifdef _WIN32 - DWORD last_tick_count; - struct timeval adjust_tick_count; -#endif -#if defined(HAVE_ANY_MONOTONIC) - /** True iff we should use our system's monotonic time implementation */ - /* TODO: Support systems where we don't need to detct monotonic time */ - int use_monotonic; + struct evutil_monotonic_timer monotonic_timer; + /** Difference between internal time (maybe from clock_gettime) and * gettimeofday. */ struct timeval tv_clock_diff; /** Second in which we last updated tv_clock_diff, in monotonic time. */ time_t last_updated_clock_diff; -#endif #ifndef EVENT__DISABLE_THREAD_SUPPORT /* threading support */ @@ -413,4 +382,3 @@ int event_base_foreach_event_(struct event_base *base, #endif #endif /* EVENT_INTERNAL_H_INCLUDED_ */ - -- cgit v1.2.1