in pthread library it is possible to find non blocking function:
int pthread_mutex_trylock(pthread_mutex_t *mutex);
can I find something similar in Windows?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you are using a critical section for your lock then the equivalent is
TryEnterCriticalSection().If you are using a mutex for your lock then the equivalent is to call
WaitForSingleObject()passing0as the timeout.If you are unfamiliar with Windows synchronisation objects, don’t be fooled into preferring the mutex because it has a name that you are most familiar with from a pthreads background. So long as your synchronisation is within process, critical sections are more efficient and easier to use.