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 (156). 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 FairCom DB Error Codes for a complete listing of valid FairCom DB 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, ctThrdMutexRel