F.67 ctThrdMutexTry
Try to acquire mutex immediately.
Short Name
ctThrdMutexTry
TYPE
Threading function
DECLARATION
NINT ctThrdMutexTry(pctMUTEX mutex)DESCRIPTION
ctThrdMutexTry attempts to acquire the mutex immediately.
RETURN
If unsuccessful, ctThrdMutexTry returns with a value of NTIM_ERR. If successful, ctThrdMutexTry returns with a value of zero. On error, check sysiocod for the system level error return.
Value Symbolic Constant Explanation 0 NO_ERROR mutex not in use. 156 NTIM_ERR mutex in use by another thread. Timeout error.
See Appendix A "c-tree Plus Error Codes" of the c-tree Plus Programmer's Reference Guide for a complete listing of valid c-tree Plus error values.
EXAMPLE
pctMUTEX tfin_mtx;NINT rc;COUNT retry = 0;while (ctThrdMutexTry(&tfin_mtx)) {if (retry < 1000) {ctThrdSleep((LONG) 50);retry ++;} else {return(-1);}rc = tfin;ctThrdMutexRel(&tfin_mtx);LIMITATIONS
Can only be used with a ctThrd library.
SEE ALSO
ctThrdMutexGet and ctThrdMutexRel
|
FairCom Corporation www.faircom.com |