BLOG | DOCUMENTATION | TRAC

Home --> Documentations --> PJLIB Reference

timer.h
Go to the documentation of this file.
1 /* $Id: timer.h 4567 2013-07-19 06:31:28Z bennylp $ */
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 
30 
68 typedef int pj_timer_id_t;
69 
73 struct pj_timer_entry;
74 
82 typedef void pj_timer_heap_callback(pj_timer_heap_t *timer_heap,
83  struct pj_timer_entry *entry);
84 
85 
89 typedef struct pj_timer_entry
90 {
96  void *user_data;
97 
103  int id;
104 
109 
115 
121 
127 
128 #if PJ_TIMER_DEBUG
129  const char *src_file;
130  int src_line;
131 #endif
133 
134 
142 
159  pj_size_t count,
160  pj_timer_heap_t **ht);
161 
167 PJ_DECL(void) pj_timer_heap_destroy( pj_timer_heap_t *ht );
168 
169 
179 PJ_DECL(void) pj_timer_heap_set_lock( pj_timer_heap_t *ht,
180  pj_lock_t *lock,
181  pj_bool_t auto_del );
182 
192  unsigned count );
193 
211  int id,
212  void *user_data,
214 
223 
232 #if PJ_TIMER_DEBUG
233 # define pj_timer_heap_schedule(ht,e,d) \
234  pj_timer_heap_schedule_dbg(ht,e,d,__FILE__,__LINE__)
235 
236  PJ_DECL(pj_status_t) pj_timer_heap_schedule_dbg( pj_timer_heap_t *ht,
237  pj_timer_entry *entry,
238  const pj_time_val *delay,
239  const char *src_file,
240  int src_line);
241 #else
243  pj_timer_entry *entry,
244  const pj_time_val *delay);
245 #endif /* PJ_TIMER_DEBUG */
246 
262 #if PJ_TIMER_DEBUG
263 # define pj_timer_heap_schedule_w_grp_lock(ht,e,d,id,g) \
264  pj_timer_heap_schedule_w_grp_lock_dbg(ht,e,d,id,g,__FILE__,__LINE__)
265 
266  PJ_DECL(pj_status_t) pj_timer_heap_schedule_w_grp_lock_dbg(
267  pj_timer_heap_t *ht,
268  pj_timer_entry *entry,
269  const pj_time_val *delay,
270  int id_val,
271  pj_grp_lock_t *grp_lock,
272  const char *src_file,
273  int src_line);
274 #else
276  pj_timer_heap_t *ht,
277  pj_timer_entry *entry,
278  const pj_time_val *delay,
279  int id_val,
280  pj_grp_lock_t *grp_lock);
281 #endif /* PJ_TIMER_DEBUG */
282 
283 
295 PJ_DECL(int) pj_timer_heap_cancel( pj_timer_heap_t *ht,
296  pj_timer_entry *entry);
297 
313  pj_timer_entry *entry,
314  int id_val);
315 
323 
335  pj_time_val *timeval);
336 
351 PJ_DECL(unsigned) pj_timer_heap_poll( pj_timer_heap_t *ht,
352  pj_time_val *next_delay);
353 
354 #if PJ_TIMER_DEBUG
355 
360 PJ_DECL(void) pj_timer_heap_dump(pj_timer_heap_t *ht);
361 #endif
362 
368 
369 #endif /* __PJ_TIMER_H__ */
370 
struct pj_timer_heap_t pj_timer_heap_t
Definition: types.h:221
pj_time_val _timer_value
Definition: timer.h:120
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:114
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:382
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:68
void pj_timer_heap_destroy(pj_timer_heap_t *ht)
pj_timer_heap_callback * cb
Definition: timer.h:108
#define PJ_END_DECL
Definition: config.h:1067
pj_size_t pj_timer_heap_count(pj_timer_heap_t *ht)
Higher abstraction for locking objects.
void * user_data
Definition: timer.h:96
#define PJ_BEGIN_DECL
Definition: config.h:1066
pj_status_t pj_timer_heap_schedule(pj_timer_heap_t *ht, pj_timer_entry *entry, const pj_time_val *delay)
Definition: pool.h:313
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:103
Definition: timer.h:89
pj_grp_lock_t * _grp_lock
Definition: timer.h:126
void pj_timer_heap_callback(pj_timer_heap_t *timer_heap, struct pj_timer_entry *entry)
Definition: timer.h:82
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.