[Qt-interest] need some QThread help

sarvesh saran aquarian.thunder at gmail.com
Mon Apr 25 19:15:40 CEST 2011


On Mon, Apr 25, 2011 at 9:01 PM, Paul Miller <paul at fxtech.com> wrote:

> I'm doing some experimenting with using threading to solve a chicken/egg
> problem I ran into, but I'm not sure of which magic locking class to
> help with the synchronization.
>
> This is a simplified version of the problem. I need to save a rather
> large image (using my own code, not QImage), and I'm saving it 256 lines
> at a time. So I'm pushing 256 lines of data, and I need the thread to
> "consume" the 256 lines and I want the producer to wait for the consumer
> to be finished before it goes to get more lines.
>
> Looking at it from the other side, my consumer is going to write a line
> at a time. I want it to wait for a line to be ready, write the line,
> then go back to waiting. The producer function will be able to provide
> 256 lines at once, but should wait for all 256 lines to be consumed
> before returning.
>
> I think a simple semaphore is all I need but my tests so far haven't
> worked right. Any suggestions?
>



On Mon, Apr 25, 2011 at 9:01 PM, Paul Miller <paul at fxtech.com> wrote:

> I'm doing some experimenting with using threading to solve a chicken/egg
> problem I ran into, but I'm not sure of which magic locking class to
> help with the synchronization.
>
> This is a simplified version of the problem. I need to save a rather
> large image (using my own code, not QImage), and I'm saving it 256 lines
> at a time. So I'm pushing 256 lines of data, and I need the thread to
> "consume" the 256 lines and I want the producer to wait for the consumer
> to be finished before it goes to get more lines.
>
> Looking at it from the other side, my consumer is going to write a line
> at a time. I want it to wait for a line to be ready, write the line,
> then go back to waiting. The producer function will be able to provide
> 256 lines at once, but should wait for all 256 lines to be consumed
> before returning.
>

waitcondition example:

http://doc.trolltech.com/latest/threads-waitconditions.html

and

http://labs.qt.nokia.com/2006/12/04/threading-without-the-headache/

if you've already been through these links, then you can share snippets from
your test and maybe we can help.

thanks,
Sarvesh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110425/be83953d/attachment.html 


More information about the Qt-interest-old mailing list