BLOG | DOCUMENTATION | GITHUB

Home --> Documentations --> PJLIB Reference

timer.h
Go to the documentation of this file.
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15 */
16
17#ifndef __PJ_TIMER_H__
18#define __PJ_TIMER_H__
19
25#include <pj/types.h>
26#include <pj/lock.h>
27
28#if PJ_TIMER_USE_LINKED_LIST
29# include <pj/list.h>
30#endif
31
33
71typedef int pj_timer_id_t;
72
76struct pj_timer_entry;
77
85typedef void pj_timer_heap_callback(pj_timer_heap_t *timer_heap,
86 struct pj_timer_entry *entry);
87
88
92typedef struct pj_timer_entry
93{
94#if !PJ_TIMER_USE_COPY && PJ_TIMER_USE_LINKED_LIST
99#endif
100
107
113 int id;
114
119
128
129#if !PJ_TIMER_USE_COPY
135
141
142#if PJ_TIMER_DEBUG
143 const char *src_file;
144 int src_line;
145#endif
146
147#endif
149
150
158
175 pj_size_t count,
176 pj_timer_heap_t **ht);
177
184
185
196 pj_lock_t *lock,
197 pj_bool_t auto_del );
198
208 unsigned count );
209
227 int id,
228 void *user_data,
230
239
248#if PJ_TIMER_DEBUG
249# define pj_timer_heap_schedule(ht,e,d) \
250 pj_timer_heap_schedule_dbg(ht,e,d,__FILE__,__LINE__)
251
252 PJ_DECL(pj_status_t) pj_timer_heap_schedule_dbg( pj_timer_heap_t *ht,
253 pj_timer_entry *entry,
254 const pj_time_val *delay,
255 const char *src_file,
256 int src_line);
257#else
259 pj_timer_entry *entry,
260 const pj_time_val *delay);
261#endif /* PJ_TIMER_DEBUG */
262
278#if PJ_TIMER_DEBUG
279# define pj_timer_heap_schedule_w_grp_lock(ht,e,d,id,g) \
280 pj_timer_heap_schedule_w_grp_lock_dbg(ht,e,d,id,g,__FILE__,__LINE__)
281
282 PJ_DECL(pj_status_t) pj_timer_heap_schedule_w_grp_lock_dbg(
283 pj_timer_heap_t *ht,
284 pj_timer_entry *entry,
285 const pj_time_val *delay,
286 int id_val,
287 pj_grp_lock_t *grp_lock,
288 const char *src_file,
289 int src_line);
290#else
292 pj_timer_heap_t *ht,
293 pj_timer_entry *entry,
294 const pj_time_val *delay,
295 int id_val,
296 pj_grp_lock_t *grp_lock);
297#endif /* PJ_TIMER_DEBUG */
298
299
312 pj_timer_entry *entry);
313
329 pj_timer_entry *entry,
330 int id_val);
331
339
351 pj_time_val *timeval);
352
367PJ_DECL(unsigned) pj_timer_heap_poll( pj_timer_heap_t *ht,
368 pj_time_val *next_delay);
369
370#if PJ_TIMER_DEBUG
376PJ_DECL(void) pj_timer_heap_dump(pj_timer_heap_t *ht);
377#endif
378
384
385#endif /* __PJ_TIMER_H__ */
386
int pj_bool_t
Definition: types.h:71
struct pj_lock_t pj_lock_t
Definition: types.h:239
size_t pj_size_t
Definition: types.h:58
int pj_status_t
Definition: types.h:68
struct pj_grp_lock_t pj_grp_lock_t
Definition: types.h:242
struct pj_timer_heap_t pj_timer_heap_t
Definition: types.h:221
#define PJ_DECL_LIST_MEMBER(type)
Definition: list.h:61
pj_size_t pj_timer_heap_count(pj_timer_heap_t *ht)
void pj_timer_heap_callback(pj_timer_heap_t *timer_heap, struct pj_timer_entry *entry)
Definition: timer.h:85
pj_status_t pj_timer_heap_schedule_w_grp_lock(pj_timer_heap_t *ht, pj_timer_entry *entry, const pj_time_val *delay, int id_val, pj_grp_lock_t *grp_lock)
int pj_timer_heap_cancel_if_active(pj_timer_heap_t *ht, pj_timer_entry *entry, int id_val)
int pj_timer_heap_cancel(pj_timer_heap_t *ht, pj_timer_entry *entry)
unsigned pj_timer_heap_poll(pj_timer_heap_t *ht, pj_time_val *next_delay)
pj_status_t pj_timer_heap_earliest_time(pj_timer_heap_t *ht, pj_time_val *timeval)
void pj_timer_heap_destroy(pj_timer_heap_t *ht)
pj_status_t pj_timer_heap_schedule(pj_timer_heap_t *ht, pj_timer_entry *entry, const pj_time_val *delay)
int pj_timer_id_t
Definition: timer.h:71
pj_timer_entry * pj_timer_entry_init(pj_timer_entry *entry, int id, void *user_data, pj_timer_heap_callback *cb)
pj_size_t pj_timer_heap_mem_size(pj_size_t count)
pj_status_t pj_timer_heap_create(pj_pool_t *pool, pj_size_t count, pj_timer_heap_t **ht)
pj_bool_t pj_timer_entry_running(pj_timer_entry *entry)
void pj_timer_heap_set_lock(pj_timer_heap_t *ht, pj_lock_t *lock, pj_bool_t auto_del)
unsigned pj_timer_heap_set_max_timed_out_per_poll(pj_timer_heap_t *ht, unsigned count)
#define PJ_BEGIN_DECL
Definition: config.h:1284
#define PJ_END_DECL
Definition: config.h:1285
Linked List data structure.
Higher abstraction for locking objects.
Definition: pool.h:310
Definition: types.h:397
Definition: timer.h:93
pj_timer_heap_callback * cb
Definition: timer.h:118
pj_timer_id_t _timer_id
Definition: timer.h:127
pj_time_val _timer_value
Definition: timer.h:134
int id
Definition: timer.h:113
void * user_data
Definition: timer.h:106
pj_grp_lock_t * _grp_lock
Definition: timer.h:140
Declaration of basic types and utility.

 


PJLIB Open Source, high performance, small footprint, and very very portable framework
Copyright (C) 2006-2009 Teluu Inc.