BLOG | DOCUMENTATION | TRAC

Home --> Documentations --> PJLIB Reference

timer.h
Go to the documentation of this file.
1 /* $Id$ */
2 /*
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  */
17 
18 #ifndef __PJ_TIMER_H__
19 #define __PJ_TIMER_H__
20 
26 #include <pj/types.h>
27 #include <pj/lock.h>
28 
29 #if PJ_TIMER_USE_LINKED_LIST
30 # include <pj/list.h>
31 #endif
32 
34 
72 typedef int pj_timer_id_t;
73 
77 struct pj_timer_entry;
78 
86 typedef void pj_timer_heap_callback(pj_timer_heap_t *timer_heap,
87  struct pj_timer_entry *entry);
88 
89 
93 typedef struct pj_timer_entry
94 {
95 #if !PJ_TIMER_USE_COPY && PJ_TIMER_USE_LINKED_LIST
96 
100 #endif
101 
107  void *user_data;
108 
114  int id;
115 
120 
129 
130 #if !PJ_TIMER_USE_COPY
131 
136 
142 
143 #if PJ_TIMER_DEBUG
144  const char *src_file;
145  int src_line;
146 #endif
147 
148 #endif
150 
151 
159 
176  pj_size_t count,
177  pj_timer_heap_t **ht);
178 
184 PJ_DECL(void) pj_timer_heap_destroy( pj_timer_heap_t *ht );
185 
186 
196 PJ_DECL(void) pj_timer_heap_set_lock( pj_timer_heap_t *ht,
197  pj_lock_t *lock,
198  pj_bool_t auto_del );
199 
209  unsigned count );
210 
228  int id,
229  void *user_data,
231 
240 
249 #if PJ_TIMER_DEBUG
250 # define pj_timer_heap_schedule(ht,e,d) \
251  pj_timer_heap_schedule_dbg(ht,e,d,__FILE__,__LINE__)
252 
253  PJ_DECL(pj_status_t) pj_timer_heap_schedule_dbg( pj_timer_heap_t *ht,
254  pj_timer_entry *entry,
255  const pj_time_val *delay,
256  const char *src_file,
257  int src_line);
258 #else
260  pj_timer_entry *entry,
261  const pj_time_val *delay);
262 #endif /* PJ_TIMER_DEBUG */
263 
279 #if PJ_TIMER_DEBUG
280 # define pj_timer_heap_schedule_w_grp_lock(ht,e,d,id,g) \
281  pj_timer_heap_schedule_w_grp_lock_dbg(ht,e,d,id,g,__FILE__,__LINE__)
282 
283  PJ_DECL(pj_status_t) pj_timer_heap_schedule_w_grp_lock_dbg(
284  pj_timer_heap_t *ht,
285  pj_timer_entry *entry,
286  const pj_time_val *delay,
287  int id_val,
288  pj_grp_lock_t *grp_lock,
289  const char *src_file,
290  int src_line);
291 #else
293  pj_timer_heap_t *ht,
294  pj_timer_entry *entry,
295  const pj_time_val *delay,
296  int id_val,
297  pj_grp_lock_t *grp_lock);
298 #endif /* PJ_TIMER_DEBUG */
299 
300 
312 PJ_DECL(int) pj_timer_heap_cancel( pj_timer_heap_t *ht,
313  pj_timer_entry *entry);
314 
330  pj_timer_entry *entry,
331  int id_val);
332 
340 
352  pj_time_val *timeval);
353 
368 PJ_DECL(unsigned) pj_timer_heap_poll( pj_timer_heap_t *ht,
369  pj_time_val *next_delay);
370 
371 #if PJ_TIMER_DEBUG
372 
377 PJ_DECL(void) pj_timer_heap_dump(pj_timer_heap_t *ht);
378 #endif
379 
385 
386 #endif /* __PJ_TIMER_H__ */
387 
struct pj_timer_heap_t pj_timer_heap_t
Definition: types.h:221
pj_time_val _timer_value
Definition: timer.h:135
int pj_timer_heap_cancel_if_active(pj_timer_heap_t *ht, pj_timer_entry *entry, int id_val)
pj_size_t pj_timer_heap_mem_size(pj_size_t count)
pj_timer_id_t _timer_id
Definition: timer.h:128
int pj_bool_t
Definition: types.h:71
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)
Definition: types.h:379
pj_bool_t pj_timer_entry_running(pj_timer_entry *entry)
int pj_timer_heap_cancel(pj_timer_heap_t *ht, pj_timer_entry *entry)
Declaration of basic types and utility.
int pj_status_t
Definition: types.h:68
pj_status_t pj_timer_heap_earliest_time(pj_timer_heap_t *ht, pj_time_val *timeval)
struct pj_grp_lock_t pj_grp_lock_t
Definition: types.h:242
struct pj_lock_t pj_lock_t
Definition: types.h:239
int pj_timer_id_t
Definition: timer.h:72
void pj_timer_heap_destroy(pj_timer_heap_t *ht)
pj_timer_heap_callback * cb
Definition: timer.h:119
#define PJ_END_DECL
Definition: config.h:1281
pj_size_t pj_timer_heap_count(pj_timer_heap_t *ht)
#define PJ_DECL_LIST_MEMBER(type)
Definition: list.h:62
Higher abstraction for locking objects.
Linked List data structure.
void * user_data
Definition: timer.h:107
#define PJ_BEGIN_DECL
Definition: config.h:1280
pj_status_t pj_timer_heap_schedule(pj_timer_heap_t *ht, pj_timer_entry *entry, const pj_time_val *delay)
Definition: pool.h:310
unsigned pj_timer_heap_set_max_timed_out_per_poll(pj_timer_heap_t *ht, unsigned count)
pj_timer_entry * pj_timer_entry_init(pj_timer_entry *entry, int id, void *user_data, pj_timer_heap_callback *cb)
int id
Definition: timer.h:114
Definition: timer.h:93
pj_grp_lock_t * _grp_lock
Definition: timer.h:141
void pj_timer_heap_callback(pj_timer_heap_t *timer_heap, struct pj_timer_entry *entry)
Definition: timer.h:86
unsigned pj_timer_heap_poll(pj_timer_heap_t *ht, pj_time_val *next_delay)
void pj_timer_heap_set_lock(pj_timer_heap_t *ht, pj_lock_t *lock, pj_bool_t auto_del)
size_t pj_size_t
Definition: types.h:58
pj_status_t pj_timer_heap_create(pj_pool_t *pool, pj_size_t count, pj_timer_heap_t **ht)

 


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