Main Page | Modules | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

Thread Mutex Routines
[Brought To You By APR]


Defines

#define SWITCH_MUTEX_DEFAULT   0x0
#define SWITCH_MUTEX_NESTED   0x1
#define SWITCH_MUTEX_UNNESTED   0x2

Typedefs

typedef apr_thread_mutex_t switch_mutex_t

Functions

switch_status_t switch_mutex_init (switch_mutex_t **lock, unsigned int flags, switch_memory_pool_t *pool)
switch_status_t switch_mutex_destroy (switch_mutex_t *lock)
switch_status_t switch_mutex_lock (switch_mutex_t *lock)
switch_status_t switch_mutex_unlock (switch_mutex_t *lock)
switch_status_t switch_mutex_trylock (switch_mutex_t *lock)


Define Documentation

#define SWITCH_MUTEX_DEFAULT   0x0
 

platform-optimal lock behavior

#define SWITCH_MUTEX_NESTED   0x1
 

enable nested (recursive) locks

#define SWITCH_MUTEX_UNNESTED   0x2
 

disable nested locks


Typedef Documentation

typedef struct apr_thread_mutex_t switch_mutex_t
 

Opaque thread-local mutex structure


Function Documentation

switch_status_t switch_mutex_destroy switch_mutex_t lock  ) 
 

Destroy the mutex and free the memory associated with the lock.

Parameters:
lock the mutex to destroy.
00202 {
00203         return apr_thread_mutex_destroy(lock);
00204 }

switch_status_t switch_mutex_init switch_mutex_t **  lock,
unsigned int  flags,
switch_memory_pool_t pool
 

Create and initialize a mutex that can be used to synchronize threads.

Parameters:
lock the memory address where the newly created mutex will be stored.
flags Or'ed value of:
           SWITCH_THREAD_MUTEX_DEFAULT   platform-optimal lock behavior.
           SWITCH_THREAD_MUTEX_NESTED    enable nested (recursive) locks.
           SWITCH_THREAD_MUTEX_UNNESTED  disable nested locks (non-recursive).
 
pool the pool from which to allocate the mutex.
Warning:
Be cautious in using SWITCH_THREAD_MUTEX_DEFAULT. While this is the most optimial mutex based on a given platform's performance charateristics, it will behave as either a nested or an unnested lock.
00197 {
00198         return apr_thread_mutex_create(lock, flags, pool);
00199 }

switch_status_t switch_mutex_lock switch_mutex_t lock  ) 
 

Acquire the lock for the given mutex. If the mutex is already locked, the current thread will be put to sleep until the lock becomes available.

Parameters:
lock the mutex on which to acquire the lock.
00207 {
00208         return apr_thread_mutex_lock(lock);
00209 }

switch_status_t switch_mutex_trylock switch_mutex_t lock  ) 
 

Attempt to acquire the lock for the given mutex. If the mutex has already been acquired, the call returns immediately with APR_EBUSY. Note: it is important that the APR_STATUS_IS_EBUSY(s) macro be used to determine if the return value was APR_EBUSY, for portability reasons.

Parameters:
lock the mutex on which to attempt the lock acquiring.
00217 {
00218         return apr_thread_mutex_trylock(lock);
00219 }

switch_status_t switch_mutex_unlock switch_mutex_t lock  ) 
 

Release the lock for the given mutex.

Parameters:
lock the mutex from which to release the lock.
00212 {
00213         return apr_thread_mutex_unlock(lock);
00214 }


Generated on Fri Oct 10 11:24:22 2008 for FreeSWITCH by  doxygen 1.3.9.1