[Qt-interest] efficient Wait for Thread finished?
Arnold Krille
arnold at arnoldarts.de
Tue Jan 20 13:30:30 CET 2009
On Tuesday 20 January 2009 12:04:32 Bradley T. Hughes wrote:
> Matthias Pospiech wrote:
> > How should it look like?
> Why aren't you using QThread::wait()?
Anything with wait( X ) is a not so optimal solution as the quantization you
choose for the wait will have an influence on the performance. Either you are
checking to often, thus stealing valuable calculation time or you are checking
not often enough and thus introduce dead-time.
As the various mutexes and semaphores in Qt have platform-specific
implementations, these allow for the waiting thread to really sleep and get
woken up by the kernel/os only when the condition is met (or a timeout
occured), not at regular intervals.
Another solution would be to use a ringbuffer (or fifo) for the communications.
This would have several advantages: The buffer would only need a lock when it
gets full and the reading thread could read (and save) multiple datasets at
once which could make better use of disk-bandwidth.
Have fun,
Arnold
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090120/abf442db/attachment.bin
More information about the Qt-interest-old
mailing list