BLOG | DOCUMENTATION | TRAC

Home --> Documentations --> PJLIB Reference

lock.h
Go to the documentation of this file.
1 /* $Id: lock.h 4359 2013-02-21 11:18:36Z bennylp $ */
2 /*
3  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 #ifndef __PJ_LOCK_H__
21 #define __PJ_LOCK_H__
22 
27 #include <pj/types.h>
28 
30 
56  const char *name,
57  pj_lock_t **lock );
58 
69  const char *name,
70  pj_lock_t **lock );
71 
72 
84  const char *name,
85  pj_lock_t **lock );
86 
87 
88 #if defined(PJ_HAS_SEMAPHORE) && PJ_HAS_SEMAPHORE != 0
89 
101  const char *name,
102  unsigned initial,
103  unsigned max,
104  pj_lock_t **lock );
105 
106 #endif /* PJ_HAS_SEMAPHORE */
107 
115 PJ_DECL(pj_status_t) pj_lock_acquire( pj_lock_t *lock );
116 
117 
125 PJ_DECL(pj_status_t) pj_lock_tryacquire( pj_lock_t *lock );
126 
127 
135 PJ_DECL(pj_status_t) pj_lock_release( pj_lock_t *lock );
136 
137 
145 PJ_DECL(pj_status_t) pj_lock_destroy( pj_lock_t *lock );
146 
147 
187 typedef struct pj_grp_lock_config
188 {
192  unsigned flags;
193 
195 
196 
203 
217  const pj_grp_lock_config *cfg,
218  pj_grp_lock_t **p_grp_lock);
219 
227 PJ_DECL(pj_status_t) pj_grp_lock_destroy( pj_grp_lock_t *grp_lock);
228 
239  pj_grp_lock_t *new_lock);
240 
248 PJ_DECL(pj_status_t) pj_grp_lock_acquire( pj_grp_lock_t *grp_lock);
249 
259 
269 PJ_DECL(pj_status_t) pj_grp_lock_release( pj_grp_lock_t *grp_lock);
270 
283  pj_pool_t *pool,
284  void *member,
285  void (*handler)(void *member));
286 
298  void *member,
299  void (*handler)(void *member));
300 
308 #if !PJ_GRP_LOCK_DEBUG
309 PJ_DECL(pj_status_t) pj_grp_lock_add_ref(pj_grp_lock_t *grp_lock);
310 
311 #define pj_grp_lock_add_ref_dbg(grp_lock, x, y) pj_grp_lock_add_ref(grp_lock)
312 
313 #else
314 
315 #define pj_grp_lock_add_ref(g) pj_grp_lock_add_ref_dbg(g, __FILE__, __LINE__)
316 
317 PJ_DECL(pj_status_t) pj_grp_lock_add_ref_dbg(pj_grp_lock_t *grp_lock,
318  const char *file,
319  int line);
320 #endif
321 
330 #if !PJ_GRP_LOCK_DEBUG
331 PJ_DECL(pj_status_t) pj_grp_lock_dec_ref(pj_grp_lock_t *grp_lock);
332 
333 #define pj_grp_lock_dec_ref_dbg(grp_lock, x, y) pj_grp_lock_dec_ref(grp_lock)
334 #else
335 
336 #define pj_grp_lock_dec_ref(g) pj_grp_lock_dec_ref_dbg(g, __FILE__, __LINE__)
337 
338 PJ_DECL(pj_status_t) pj_grp_lock_dec_ref_dbg(pj_grp_lock_t *grp_lock,
339  const char *file,
340  int line);
341 
342 #endif
343 
352 PJ_DECL(int) pj_grp_lock_get_ref(pj_grp_lock_t *grp_lock);
353 
354 
363 PJ_DECL(void) pj_grp_lock_dump(pj_grp_lock_t *grp_lock);
364 
365 
384  pj_lock_t *ext_lock,
385  int pos);
386 
396  pj_lock_t *ext_lock);
397 
398 
403 
404 
405 #endif /* __PJ_LOCK_H__ */
406 
pj_status_t pj_lock_tryacquire(pj_lock_t *lock)
pj_status_t pj_grp_lock_release(pj_grp_lock_t *grp_lock)
pj_status_t pj_grp_lock_add_ref(pj_grp_lock_t *grp_lock)
pj_status_t pj_lock_acquire(pj_lock_t *lock)
pj_status_t pj_lock_create_null_mutex(pj_pool_t *pool, const char *name, pj_lock_t **lock)
pj_status_t pj_grp_lock_dec_ref(pj_grp_lock_t *grp_lock)
pj_status_t pj_grp_lock_acquire(pj_grp_lock_t *grp_lock)
void pj_grp_lock_dump(pj_grp_lock_t *grp_lock)
Declaration of basic types and utility.
pj_status_t pj_lock_create_recursive_mutex(pj_pool_t *pool, const char *name, pj_lock_t **lock)
int pj_status_t
Definition: types.h:68
pj_status_t pj_grp_lock_tryacquire(pj_grp_lock_t *grp_lock)
pj_status_t pj_grp_lock_unchain_lock(pj_grp_lock_t *grp_lock, pj_lock_t *ext_lock)
pj_status_t pj_lock_create_simple_mutex(pj_pool_t *pool, const char *name, pj_lock_t **lock)
unsigned flags
Definition: lock.h:192
void pj_grp_lock_config_default(pj_grp_lock_config *cfg)
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_grp_lock_get_ref(pj_grp_lock_t *grp_lock)
pj_status_t pj_grp_lock_create(pj_pool_t *pool, const pj_grp_lock_config *cfg, pj_grp_lock_t **p_grp_lock)
#define PJ_END_DECL
Definition: config.h:1067
pj_status_t pj_grp_lock_del_handler(pj_grp_lock_t *grp_lock, void *member, void(*handler)(void *member))
pj_status_t pj_grp_lock_chain_lock(pj_grp_lock_t *grp_lock, pj_lock_t *ext_lock, int pos)
pj_status_t pj_grp_lock_add_handler(pj_grp_lock_t *grp_lock, pj_pool_t *pool, void *member, void(*handler)(void *member))
#define PJ_BEGIN_DECL
Definition: config.h:1066
pj_status_t pj_lock_create_semaphore(pj_pool_t *pool, const char *name, unsigned initial, unsigned max, pj_lock_t **lock)
pj_status_t pj_grp_lock_destroy(pj_grp_lock_t *grp_lock)
Definition: lock.h:187
Definition: pool.h:313
pj_status_t pj_lock_release(pj_lock_t *lock)
pj_status_t pj_grp_lock_replace(pj_grp_lock_t *old_lock, pj_grp_lock_t *new_lock)
pj_status_t pj_lock_destroy(pj_lock_t *lock)

 


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