BLOG | DOCUMENTATION | TRAC

Home --> Documentations --> PJLIB Reference

lock.h
Go to the documentation of this file.
1 /* $Id: lock.h 4992 2015-03-06 06:09:22Z ming $ */
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 
236  const pj_grp_lock_config *cfg,
237  void *member,
238  void (*handler)(void *member),
239  pj_grp_lock_t **p_grp_lock);
240 
248 PJ_DECL(pj_status_t) pj_grp_lock_destroy( pj_grp_lock_t *grp_lock);
249 
260  pj_grp_lock_t *new_lock);
261 
269 PJ_DECL(pj_status_t) pj_grp_lock_acquire( pj_grp_lock_t *grp_lock);
270 
280 
290 PJ_DECL(pj_status_t) pj_grp_lock_release( pj_grp_lock_t *grp_lock);
291 
304  pj_pool_t *pool,
305  void *member,
306  void (*handler)(void *member));
307 
319  void *member,
320  void (*handler)(void *member));
321 
329 #if !PJ_GRP_LOCK_DEBUG
330 PJ_DECL(pj_status_t) pj_grp_lock_add_ref(pj_grp_lock_t *grp_lock);
331 
332 #define pj_grp_lock_add_ref_dbg(grp_lock, x, y) pj_grp_lock_add_ref(grp_lock)
333 
334 #else
335 
336 #define pj_grp_lock_add_ref(g) pj_grp_lock_add_ref_dbg(g, __FILE__, __LINE__)
337 
338 PJ_DECL(pj_status_t) pj_grp_lock_add_ref_dbg(pj_grp_lock_t *grp_lock,
339  const char *file,
340  int line);
341 #endif
342 
351 #if !PJ_GRP_LOCK_DEBUG
352 PJ_DECL(pj_status_t) pj_grp_lock_dec_ref(pj_grp_lock_t *grp_lock);
353 
354 #define pj_grp_lock_dec_ref_dbg(grp_lock, x, y) pj_grp_lock_dec_ref(grp_lock)
355 #else
356 
357 #define pj_grp_lock_dec_ref(g) pj_grp_lock_dec_ref_dbg(g, __FILE__, __LINE__)
358 
359 PJ_DECL(pj_status_t) pj_grp_lock_dec_ref_dbg(pj_grp_lock_t *grp_lock,
360  const char *file,
361  int line);
362 
363 #endif
364 
373 PJ_DECL(int) pj_grp_lock_get_ref(pj_grp_lock_t *grp_lock);
374 
375 
384 PJ_DECL(void) pj_grp_lock_dump(pj_grp_lock_t *grp_lock);
385 
386 
405  pj_lock_t *ext_lock,
406  int pos);
407 
417  pj_lock_t *ext_lock);
418 
419 
424 
425 
426 #endif /* __PJ_LOCK_H__ */
427 
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)
pj_status_t pj_grp_lock_create_w_handler(pj_pool_t *pool, const pj_grp_lock_config *cfg, void *member, void(*handler)(void *member), pj_grp_lock_t **p_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:1096
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:1095
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.