Actually, how about something like this:
class QThread
{
// ...
public:
enum TimeUnit
{
Seconds,
Milliseconds,
Microseconds
};
void sleep(unsigned long time, TimeUnit units);
};
One could also envisage TimeUnit being in the Qt namespace rather than within
QThread if other classes might find it useful.
On 24/08/2011, at 12:03 PM, <[email protected]> wrote:
> 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
--
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