I figure this might be the right time to scratch an itch with QThread. :-P

It has often annoyed me how the sleep(), msleep() and usleep() functions of 
QThread are protected and not public. A number of times I've found myself in 
the situation where I want to call these from outside of a QThread subclass and 
have had to resort to defining a dummy subclass just so I could call them. The 
only rationale I can think of for why these were made protected is to try to 
ensure that they are only called from threads that were indeed created by 
QThread (not sure if that is even necessary for these functions to work).

I propose that for Qt5, one of three things be done:

(1) Make sleep(), msleep() and usleep() public static functions. This would be 
source compatible but would also allow them to be called from any thread, not 
just those that were created with a QThread.

(2) Make sleep(), msleep() and usleep() public member functions. This would not 
be source compatible but it would force the current thread to be obtained by 
calling QThread::currentThread() and then calling the sleep-related functions 
through that. The only source incompatibility would be a static function in a 
QThread subclass calling one of the sleep-related functions.

(3) Deprecate the sleep(), msleep() and usleep() functions for Qt5 and provide 
public member functions with different names, such as sleepSec(), sleepMsec() 
and sleepUsec(). I'm not at all attached to these suggested names, by the way. 
;)


Of these options, I think (3) is probably the most promising.

--
Dr Craig Scott
Computational Software Engineering Team Leader, CSIRO (CMIS)
Melbourne, Australia



_______________________________________________
Qt5-feedback mailing list
[email protected]
http://lists.qt.nokia.com/mailman/listinfo/qt5-feedback

Reply via email to