TutRwMutexReadLock


Name

TutRwMutexReadLock — read-lock a R/W mutex

Synopsis

T_BOOL TutRwMutexReadLock(rw_mutex) 
T_RW_MUTEX rw_mutex; 

Arguments

rw_mutex — R/W mutex object to lock

Return Values

TRUE if lock was granted, FALSE otherwise.

Diagnostics

If TutRwMutexReadLock fails, it returns FALSE and sets the global SmartSockets error number to one of:

Description

TutRwMutexReadLock read-locks a R/W mutex. A read-lock implies that the thread may safely examine (but not modify) the state of the resource protected by the R/W mutex. Read-locks may be held simultaneously by more than one thread.

Like normal mutexes, R/W mutexes can be recursively locked. A thread is never suspended by a recursive lock operation. This means that a thread already granted a read-lock always succeeds immediately in obtaining another read-lock, and a thread already granted a write-lock succeeds immediately in obtaining either a read-lock or a write-lock. A single thread holding multiple read-locks is still only a single reader-thread so far as the quota is concerned.

Caution

Every call to TutRwMutexReadLock should be balanced by a subsequent call to TutRwMutexUnlock.

See Also

TutRwMutexCreate, TutRwMutexUnlock, TutRwMutexWriteLock

Examples

This example read-locks a R/W mutex:

T_RW_MUTEX rw_mutex; 
. 
. 
. 
if (!TutRwMutexReadLock(rw_mutex)) { 
  /* error */ 
} 

TIBCO SmartSockets™ Utilities
Software Release 6.8, July 2006
Copyright © TIBCO Software Inc. All rights reserved
www.tibco.com