rabbitmq-c
0.5.3
C AMQP Client library for RabbitMQ
|
00001 /* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */ 00002 /* 00003 * Portions created by Alan Antonuk are Copyright (c) 2013-2014 Alan Antonuk. 00004 * All Rights Reserved. 00005 * 00006 * Permission is hereby granted, free of charge, to any person obtaining a 00007 * copy of this software and associated documentation files (the "Software"), 00008 * to deal in the Software without restriction, including without limitation 00009 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00010 * and/or sell copies of the Software, and to permit persons to whom the 00011 * Software is furnished to do so, subject to the following conditions: 00012 * 00013 * The above copyright notice and this permission notice shall be included in 00014 * all copies or substantial portions of the Software. 00015 * 00016 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00017 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00018 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00019 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00020 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 00021 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 00022 * DEALINGS IN THE SOFTWARE. 00023 */ 00024 #ifndef AMQP_TIMER_H 00025 #define AMQP_TIMER_H 00026 00027 #include <stdint.h> 00028 00029 #ifdef _WIN32 00030 # ifndef WINVER 00031 # define WINVER 0x0502 00032 # endif 00033 # ifndef WIN32_LEAN_AND_MEAN 00034 # define WIN32_LEAN_AND_MEAN 00035 # endif 00036 # include <Winsock2.h> 00037 #else 00038 # include <sys/time.h> 00039 #endif 00040 00041 #define AMQP_MS_PER_S 1000 00042 #define AMQP_US_PER_MS 1000 00043 #define AMQP_NS_PER_S 1000000000 00044 #define AMQP_NS_PER_MS 1000000 00045 #define AMQP_NS_PER_US 1000 00046 00047 #define AMQP_INIT_TIMER(structure) { \ 00048 structure.current_timestamp = 0; \ 00049 structure.timeout_timestamp = 0; \ 00050 } 00051 00052 typedef struct amqp_timer_t_ { 00053 uint64_t current_timestamp; 00054 uint64_t timeout_timestamp; 00055 uint64_t ns_until_next_timeout; 00056 struct timeval tv; 00057 } amqp_timer_t; 00058 00059 /* Gets a monotonic timestamp in ns */ 00060 uint64_t 00061 amqp_get_monotonic_timestamp(void); 00062 00063 /* Prepare timeout value and modify timer state based on timer state. */ 00064 int 00065 amqp_timer_update(amqp_timer_t *timer, struct timeval *timeout); 00066 00067 #endif /* AMQP_TIMER_H */