TutMutexLock


Name

TutMutexLock — lock a mutex object

Synopsis

T_BOOL TutMutexLock(mutex, timeout) 
T_MUTEX mutex; 
T_REAL8 timeout; 

Arguments

mutex — mutex object to lock

timeout — maximum number of seconds to wait for mutex

Return Values

TRUE if mutex object was successfully locked, FALSE otherwise.

Diagnostics

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

Description

TutMutexLock attempts to lock a mutex object. If mutex is not immediately available, the calling thread is suspended until the mutex becomes available or until the timeout period specified has expired. The reserved timeout value T_TIMEOUT_FOREVER may be used to specify an indefinite wait.

Caution

Every call to TutMutexLock should be balanced by a subsequent call to TutMutexUnlock.

See Also

TutMutexCreate, TutMutexUnlock

Examples

This example attempts to lock a mutex object with a one-second timeout:

T_MUTEX mutex; 
... 
if (!TutMutexLock(mutex, 1.0)) { 
  if (T_ERR_TIMEOUT_REACHED != TutErrNumGet()) { 
    /* error */ 
  } 
  /* timeout */ 
  ... 
} 
... 

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