[Qt-interest] QThread::sleep versus QThread::wait
Bradley T. Hughes
bradley.hughes at nokia.com
Wed Feb 3 07:56:03 CET 2010
On 02/02/2010 09:53 PM, James Matta wrote:
> I am writing a program that uses one thread to read data out of a series of
> files and push it onto a queue, and then multiple other threads to process
> the data.
> I would like to set things up so that if the event queue grows too large the
> reading thread pauses in execution so that the processing threads can catch
> up.
> My first instinct was to simply use QThread::msleep or QThread::usleep;
> however, as I was reading the documentation I noticed the QThread::wait
> function and thought that perhaps that would work, however the description
> for QThread::wait is confusing me a bit. Can anybody clarify the differences
> and perhaps give a suggestion as to which I should use?
Sounds like you want QSemaphore or QWaitCondition instead of the QThread
functions.
QThread::wait() waits for the thread to finish (meaning return from run()).
This is definitely not what you want.
--
Bradley T. Hughes (Nokia-D-Qt/Oslo), bradley.hughes at nokia.com
Sandakervn. 116, P.O. Box 4332 Nydalen, 0402 Oslo, Norway
More information about the Qt-interest-old
mailing list