summaryrefslogtreecommitdiff
path: root/toxcore/mono_time.h
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-07-08 08:43:42 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-07-09 21:04:50 +0000
commitabc17b0f8997ab07ae66130edd5dc8c43e72c886 (patch)
tree88056839c808a9f7f8c58f55ebe273aa7b5facdb /toxcore/mono_time.h
parent4e21c065517d6e125cb1d1b9a13e886b3046b0d8 (diff)
Factor out time keeping code into its own module: mono_time.c.
It turns out, `unix_time` is also monotonic, and is used as such, so I've renamed the new functions to `mono_time_*`. 2018-07-08: ``` 00:01 <@irungentoo> the idea used to be that the unix_time() function could go backward in time but I think I might have started using it like if it could not after I changed it so that it would never go back in time ```
Diffstat (limited to 'toxcore/mono_time.h')
-rw-r--r--toxcore/mono_time.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/toxcore/mono_time.h b/toxcore/mono_time.h
new file mode 100644
index 00000000..63e0f49d
--- /dev/null
+++ b/toxcore/mono_time.h
@@ -0,0 +1,35 @@
1#ifndef C_TOXCORE_TOXCORE_MONO_TIME_H
2#define C_TOXCORE_TOXCORE_MONO_TIME_H
3
4#include <stdbool.h>
5#include <stdint.h>
6
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11typedef struct Mono_Time Mono_Time;
12
13Mono_Time *mono_time_new(void);
14void mono_time_free(Mono_Time *monotime);
15
16void mono_time_update(Mono_Time *monotime);
17uint64_t mono_time_get(const Mono_Time *monotime);
18bool mono_time_is_timeout(const Mono_Time *monotime, uint64_t timestamp, uint64_t timeout);
19
20// TODO(#405): Use per-tox monotime, delete these functions.
21void unix_time_update(void);
22uint64_t unix_time(void);
23int is_timeout(uint64_t timestamp, uint64_t timeout);
24
25/* return current UNIX time in microseconds (us). */
26uint64_t current_time_actual(void);
27
28/* return current monotonic time in milliseconds (ms). */
29uint64_t current_time_monotonic(void);
30
31#ifdef __cplusplus
32}
33#endif
34
35#endif // C_TOXCORE_TOXCORE_MONO_TIME_H