Re: [Interest] QThread sleep on QMutex

2015-07-30 Thread Keith Gardner
And my question is just theoretical: is this approach good or such sleep() implementation not so good and why? I.e. will such sleep() release processor's time for another thread or not? Using sleep() will allow the processor to work on a different thread. The issue is that sleep() will most

Re: [Interest] QThread sleep on QMutex

2015-07-30 Thread Tony Rietwyk
Igor wrote: Because in Qt 4 QThread::sleep is protected. You can unprotect it by deriving your own class from QThread and making whichever static methods public! As long as you are aware of the pitfalls (don't sleep in main thread, etc.), and much easier than messing with locks just to gain

Re: [Interest] QThread sleep on QMutex

2015-07-30 Thread Matthew Woehlke
On 2015-07-30 01:43, Igor Mironchik wrote: On 30.07.2015 00:06, Matthew Woehlke wrote: 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. You failed to mention that you are using Qt 4.x :-). If

Re: [Interest] QThread sleep on QMutex

2015-07-30 Thread Igor Mironchik
Hi, On 30.07.2015 11:31, Tony Rietwyk wrote: Igor wrote: Because in Qt 4 QThread::sleep is protected. You can unprotect it by deriving your own class from QThread and making whichever static methods public! As long as you are aware of the pitfalls (don't sleep in main thread, etc.), and

[Interest] QThread sleep on QMutex

2015-07-29 Thread Igor Mironchik
Hi, 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. Or it's not so good idea because thread will

Re: [Interest] QThread sleep on QMutex

2015-07-29 Thread Matthew Woehlke
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.

Re: [Interest] QThread sleep on QMutex

2015-07-29 Thread Thiago Macieira
On Wednesday 29 July 2015 23:55:30 Igor Mironchik wrote: Hi, 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? No. QMutex mutex; mutex.lock(); mutex.tryLock( int msecs ); // This will make

Re: [Interest] QThread sleep on QMutex

2015-07-29 Thread Igor Mironchik
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 ); //