[Interest] QThread & sleep on QMutex

Igor Mironchik igor.mironchik at gmail.com
Thu Jul 30 07:43:09 CEST 2015



On 30.07.2015 00:06, Matthew Woehlke wrote:
> On 2015-07-29 16:55, Igor Mironchik wrote:
>> I hope that in this list I will find experts of synchronization and so on.
>>
>> My question: is it good to make thread's sleep on mutex like this?
>>
>> QMutex mutex;
>> mutex.lock();
>> mutex.tryLock( int msecs ); // This will make sleep for the given timeout.
> If the mutex is recursive, this will return immediately, having
> successfully locked the mutex (again). You'll need to unlock it twice as
> a result.

Mutex is not recursive.

>
> Why are you doing this? If the intent is just to make the thread sleep,
> why not use QThread::msleep?


Because in Qt 4 QThread::sleep is protected.

-- 
Best Regards,
Igor Mironchik.




More information about the Interest mailing list