Add support for pthread_mutex_trylock() semantics
As described in http://www.gimpel.com/Discussion.cfm?ThreadID=3793 this functionality is needed.
For example, this function results in lint warning 455 (A thread mutex that had not been locked is being unlocked):
bool IsLocked()
{
int retStat = pthread_mutex_trylock(&m_pthreadMutex);
if (retStat == 0)
{
// Mutex was not locked, but is now.
pthread_mutex_unlock(&m_pthreadMutex);
return (false);
}
else if (retStat == EBUSY)
{
// Mutex is already locked.
return (true);
}
return (false);
}
17
votes
![](https://secure.gravatar.com/avatar/28c652bddd08fcc8f4a8a0796e1c4a87?size=40&default=https%3A%2F%2Fassets.uvcdn.com%2Fpkg%2Fadmin%2Ficons%2Fuser_70-6bcf9e08938533adb9bac95c3e487cb2a6d4a32f890ca6fdc82e3072e0ea0368.png)