yumapro  24.10-2
YumaPro SDK
Loading...
Searching...
No Matches
agt_timer.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 - 2012, Andy Bierman, All Rights Reserved.
3 * Copyright (c) 2012 - 2021, YumaWorks, Inc., All Rights Reserved.
4 *
5 * Unless required by applicable law or agreed to in writing,
6 * software distributed under the License is distributed on an
7 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8 * KIND, either express or implied. See the License for the
9 * specific language governing permissions and limitations
10 * under the License.
11 */
12#ifndef _H_agt_timer
13#define _H_agt_timer
14
15/* FILE: agt_timer.h
16*********************************************************************
17* *
18* P U R P O S E *
19* *
20*********************************************************************/
21
28/*********************************************************************
29* *
30* C H A N G E H I S T O R Y *
31* *
32*********************************************************************
33
34date init comment
35----------------------------------------------------------------------
3623-jan-07 abb Begun
37
38*/
39
40#include <time.h>
41
42#ifndef _H_dlq
43#include "dlq.h"
44#endif
45
46#ifndef _H_status
47#include "status.h"
48#endif
49
50#ifdef __cplusplus
51extern "C" {
52#endif
53
54
67/********************************************************************
68* *
69* T Y P E S *
70* *
71*********************************************************************/
72
85typedef int (*agt_timer_fn_t) (uint32 timer_id,
86 void *cookie);
87
88
90typedef struct agt_timer_cb_t_ {
92 dlq_hdr_t qhdr;
93
96
98 uint32 timer_id;
99
102
105
108
112
113
114/********************************************************************
115* *
116* F U N C T I O N S *
117* *
118*********************************************************************/
119
120
125extern void
126 agt_timer_init (void);
127
128
134extern void
135 agt_timer_cleanup (void);
136
137
143extern void
144 agt_timer_handler (void);
145
146
164extern status_t
165 agt_timer_create (uint32 seconds,
166 boolean is_periodic,
167 agt_timer_fn_t timer_fn,
168 void *cookie,
169 uint32 *ret_timer_id);
170
171
183extern status_t
184 agt_timer_restart (uint32 timer_id,
185 uint32 seconds);
186
187
197extern void
198 agt_timer_delete (uint32 timer_id);
199
200
214extern void
215 agt_timer_get_timenow (time_t *tnow);
216
217
237extern void
238 agt_timer_get_centi_timenow (uint64 *tnow);
239
240
244#ifdef __cplusplus
245} /* end extern 'C' */
246#endif
247
248#endif /* _H_agt_timer */
dlq provides general double-linked list and queue support:
void agt_timer_handler(void)
Handle an incoming server timer polling interval.
Definition: agt_timer.c:245
status_t agt_timer_restart(uint32 timer_id, uint32 seconds)
Restart a timer with a new timeout value.
Definition: agt_timer.c:388
void agt_timer_get_centi_timenow(uint64 *tnow)
Get the current time using the system or monotonic clock.
Definition: agt_timer.c:510
int(* agt_timer_fn_t)(uint32 timer_id, void *cookie)
timer callback function
Definition: agt_timer.h:85
void agt_timer_cleanup(void)
Cleanup the agt_timer module.
Definition: agt_timer.c:222
void agt_timer_init(void)
Initialize the agt_timer module.
Definition: agt_timer.c:199
status_t agt_timer_create(uint32 seconds, boolean is_periodic, agt_timer_fn_t timer_fn, void *cookie, uint32 *ret_timer_id)
Malloc and start a new timer control block.
Definition: agt_timer.c:327
void agt_timer_get_timenow(time_t *tnow)
Get the current time using the system or monotonic clock.
Definition: agt_timer.c:453
void agt_timer_delete(uint32 timer_id)
Remove and delete a timer control block.
Definition: agt_timer.c:422
status_t
global error return code
Definition: status_enum.h:210
Global error messages for status code enumerations.
Internal Timer control block, not for use outside agt_timer.c.
Definition: agt_timer.h:90
time_t timer_start_time
save timestamp last timer start
Definition: agt_timer.h:104
dlq_hdr_t qhdr
queue header
Definition: agt_timer.h:92
agt_timer_fn_t timer_cbfn
timer popped callback
Definition: agt_timer.h:101
uint32 timer_id
assigned timer ID
Definition: agt_timer.h:98
uint32 timer_duration
timer duration in seconds, must be 1 - N
Definition: agt_timer.h:107
boolean timer_periodic
TRUE if periodic timer, FALSE for 1-shot.
Definition: agt_timer.h:95
void * timer_cookie
timer cookie passed in timer registration
Definition: agt_timer.h:110