Appendices > Portable Thread Library > Mutexes > Using trylock on a Mutex
 
Using trylock on a Mutex
Sometimes, it may be necessary to call the member function trylock on a mutex. The safe and unsafe mutexes may be created with trylock enabled by passing a Boolean value to the mutex constructor as shown below:
IlsBoolean wantTryLock = IlsTrue;
IlsUnsafeMutex* mutex = IlsUnsafeMutex(wantTryLock);
Since inter-process mutexes are required on certain machines to support the trylock, the function trylock is specified in the constructor —for example, on Windows®. Using the trylock functionality on machines where an inter-process mutex is used seriously degrades the performance of the member functions lock and unlock.

Version 5.8
Copyright © 2014, Rogue Wave Software, Inc. All Rights Reserved.