Changeset 3928
- Timestamp:
- Dec 28, 2011 9:49:24 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/include/pjsua-lib/pjsua_internal.h
r3901 r3928 367 367 pj_pool_t *pool; /**< pjsua's private pool. */ 368 368 pj_mutex_t *mutex; /**< Mutex protection for this data */ 369 unsigned mutex_nesting_level; /**< Mutex nesting level. */ 370 pj_thread_t *mutex_owner; /**< Mutex owner. */ 369 371 pjsua_state state; /**< Library state. */ 370 372 … … 503 505 504 506 #if 1 505 #define PJSUA_LOCK() pj_mutex_lock(pjsua_var.mutex) 506 #define PJSUA_TRY_LOCK() pj_mutex_trylock(pjsua_var.mutex) 507 #define PJSUA_UNLOCK() pj_mutex_unlock(pjsua_var.mutex) 507 508 PJ_INLINE(void) PJSUA_LOCK() 509 { 510 pj_mutex_lock(pjsua_var.mutex); 511 pjsua_var.mutex_owner = pj_thread_this(); 512 ++pjsua_var.mutex_nesting_level; 513 } 514 515 PJ_INLINE(void) PJSUA_UNLOCK() 516 { 517 if (--pjsua_var.mutex_nesting_level == 0) 518 pjsua_var.mutex_owner = NULL; 519 pj_mutex_unlock(pjsua_var.mutex); 520 } 521 522 PJ_INLINE(pj_status_t) PJSUA_TRY_LOCK() 523 { 524 pj_status_t status; 525 status = pj_mutex_trylock(pjsua_var.mutex); 526 if (status == PJ_SUCCESS) { 527 pjsua_var.mutex_owner = pj_thread_this(); 528 ++pjsua_var.mutex_nesting_level; 529 } 530 return status; 531 } 532 533 PJ_INLINE(pj_bool_t) PJSUA_LOCK_IS_LOCKED() 534 { 535 return pjsua_var.mutex_owner == pj_thread_this(); 536 } 537 508 538 #else 509 539 #define PJSUA_LOCK() 510 #define PJSUA_TRY_LOCK() 540 #define PJSUA_TRY_LOCK() PJ_SUCCESS 511 541 #define PJSUA_UNLOCK() 542 #define PJSUA_LOCK_IS_LOCKED() PJ_TRUE 512 543 #endif 513 544
Note: See TracChangeset
for help on using the changeset viewer.