diff options
Diffstat (limited to 'librabbitmq/amqp_timer.h')
-rw-r--r-- | librabbitmq/amqp_timer.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/librabbitmq/amqp_timer.h b/librabbitmq/amqp_timer.h index d1718af..946096d 100644 --- a/librabbitmq/amqp_timer.h +++ b/librabbitmq/amqp_timer.h @@ -25,12 +25,37 @@ #include <stdint.h> +#ifdef _WIN32 +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +# endif +# include <Winsock2.h> +#else +# include <sys/time.h> +#endif + #define AMQP_NS_PER_S 1000000000 #define AMQP_NS_PER_US 1000 +#define AMQP_INIT_TIMER(structure) { \ + structure.current_timestamp = 0; \ + structure.timeout_timestamp = 0; \ +} + +typedef struct amqp_timer_t_ { + uint64_t current_timestamp; + uint64_t timeout_timestamp; + uint64_t ns_until_next_timeout; + struct timeval tv; +} amqp_timer_t; + /* Gets a monotonic timestamp in ns */ uint64_t amqp_get_monotonic_timestamp(void); +/* Prepare timeout value and modify timer state based on timer state. */ +int +amqp_timer_update(amqp_timer_t *timer, struct timeval *timeout); + #endif /* AMQP_TIMER_H */ |