summaryrefslogtreecommitdiff
path: root/librabbitmq/amqp_timer.h
diff options
context:
space:
mode:
Diffstat (limited to 'librabbitmq/amqp_timer.h')
-rw-r--r--librabbitmq/amqp_timer.h29
1 files changed, 28 insertions, 1 deletions
diff --git a/librabbitmq/amqp_timer.h b/librabbitmq/amqp_timer.h
index d1718af..8ac3de9 100644
--- a/librabbitmq/amqp_timer.h
+++ b/librabbitmq/amqp_timer.h
@@ -25,12 +25,39 @@
#include <stdint.h>
+#ifdef _WIN32
+# ifndef WINVER
+# define WINVER 0x0502
+# endif
+# 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);
-#endif /* AMQP_TIMER_H */
+/* 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 */