Tries to lock an INKMutex
.
INKReturnCode InkMutexLockTry (INKMutex
mutex
, int
*lock
)
Tries to lock the INKMutex
. Information about
whether the lock was grabbed is set in mutex
int
*
.
lock
INKReturnCode
tells you if the call was
successful or not, but does not indicate if the lock
was grabbed.
In general, use InkMutexLockTry
to
obtain a mutex (see the example below).
If the mutex was successfully locked, then 1
is
returned.
If mutex is already locked, then 0
is returned.
int handler (INKCont contp, INKEvent event, void *edata) { //This continuation tries to grab a mutex int retval, lock = 0; retvak = InkMutexLockTry (mutex, &lock); if (!lock) { /* Schedule a retry; RETRY_TIME should be 10 ms or longer. */ INKContSchedule (contp, RETRY_TIME); return INK_EVENT_IMMEDIATE; } // Now the mutex has been grabbed do_some_job ... INKMutexUnlock (mutexp); }