PDA

View Full Version : QThread, QMutext - stability of application



googie
30th September 2009, 07:58
Hello,

As far as I found in Qt sources - when there is a problem with synchronization for threads, then only qWarning() is called.

I wonder how should I handle my problem, since I need multi-threaded and stable application, but if I let threads to work even there are synchronization problems, then whole my application is going to crash or something...

I know I can install message handler, but if I do so, then all warnings will be handled the same way and I don't think that synchronization problem is equal to some other, quiet trivial warning.

Any hints what should I do?

wysota
30th September 2009, 08:44
You should synchronize your application properly instead of relying on pure luck that no race conditions will occur.

googie
30th September 2009, 09:03
But what if lock() (or similar method) fails because of operating system? Like resources, or something else. I don't remember all reasons to make pthreads fail, but I know there are some independent from developer.

wysota
30th September 2009, 09:16
But what if lock() (or similar method) fails because of operating system?
What if your computer runs out of electicity?
I think running out of the pool of semaphores is the slightest of possible problems. And QMutex::lock() itself should not fail as in 90% of the cases it will never call a real semaphore. Only when a real lock should occur a semaphore will be instantiated.