Haka
timer.h
Go to the documentation of this file.
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 
10 #ifndef HAKA_TIMER_H
11 #define HAKA_TIMER_H
12 
13 #include <haka/types.h>
14 #include <haka/time.h>
15 #include <haka/thread.h>
16 
17 
22  TIME_REALM_REALTIME, /* Real-time timer. */
23  TIME_REALM_STATIC /* Static time. The time must be updated manually. */
24 };
25 
27 struct time_realm {
28  enum time_realm_mode mode;
29  local_storage_t states; /* struct timer_group_state */;
30 };
31 
32 struct timer;
38 typedef void (*timer_callback)(int count, void *data);
39 
43 bool time_realm_initialize(struct time_realm *realm, enum time_realm_mode mode);
44 
48 bool time_realm_destroy(struct time_realm *realm);
49 
54 void time_realm_update_and_check(struct time_realm *realm, const struct time *value);
55 
59 const struct time *time_realm_current_time(struct time_realm *realm);
60 
64 struct timer *time_realm_timer(struct time_realm *realm, timer_callback callback, void *user);
65 
69 bool time_realm_check(struct time_realm *realm);
70 
75 bool timer_init_thread();
76 
80 void timer_destroy(struct timer *timer);
81 
86 bool timer_once(struct timer *timer, struct time *delay);
87 
92 bool timer_repeat(struct timer *timer, struct time *delay);
93 
98 bool timer_stop(struct timer *timer);
99 
100 #endif /* HAKA_TIMER_H */
bool timer_once(struct timer *timer, struct time *delay)
Definition: timer.c:345
void time_realm_update_and_check(struct time_realm *realm, const struct time *value)
Definition: timer.c:144
bool time_realm_check(struct time_realm *realm)
Definition: timer.c:434
bool timer_stop(struct timer *timer)
Definition: timer.c:355
bool timer_init_thread()
Definition: timer.c:203
void(* timer_callback)(int count, void *data)
Definition: timer.h:38
void timer_destroy(struct timer *timer)
Definition: timer.c:320
time_realm_mode
Definition: timer.h:21
bool timer_repeat(struct timer *timer, struct time *delay)
Definition: timer.c:350
bool time_realm_destroy(struct time_realm *realm)
Definition: timer.c:133
bool time_realm_initialize(struct time_realm *realm, enum time_realm_mode mode)
Definition: timer.c:114
Definition: timer.h:27
pthread_key_t local_storage_t
Definition: thread.h:226
Definition: time.h:21
const struct time * time_realm_current_time(struct time_realm *realm)
Definition: timer.c:181
struct timer * time_realm_timer(struct time_realm *realm, timer_callback callback, void *user)
Definition: timer.c:216