PDA

View Full Version : Event Queue Question



TheGrimace
5th October 2007, 15:19
Is the event queue lossless? By which I mean if I queue up 30 signals, would they wait until the end of time to be processed?

I am trying to write a program that will wait in a msleep loop for the front signal until a certain condition has been met, but I am worried about leaving the other 29 signals queued.

wysota
5th October 2007, 15:30
If you don't let the queue process its events, they'll wait there. Just be aware that your application won't respond/redraw during that time.

TheGrimace
5th October 2007, 15:39
Well, in my case the GUI is in a separate thread from the thread that will have a waiting event loop. Does the event loop wait until a slot has finished before handling another signal? I think my logic may be flawed.

I was thinking along these lines.

ExampleOne objects send a string to MiddleObject which then funnels it on request to ExampleTwo objects.

So like this:

ExampleOne -> (string) -> MiddleObject -> (string) -> ExampleTwo

Both ExampleOne objects and ExampleTwo objects speak to MiddleObject through signals/slots. Right now I am a little worried about a deadlock situation where a slot holds onto the thread and doesn't allow another slot to process.

wysota
5th October 2007, 15:47
The event loop processes events sequentially. So provided that emiter and receivers are in the same thread, slots won't be run concurrently.

TheGrimace
5th October 2007, 15:53
As a potential solution, I was thinking the following: whenever a signal is processed, if the condition is not ready, sleep briefly and emit a signal with the same variables. My concern is that the signal would be processed as a direct connection. If I forced a queued connection would the other signals get a chance to process? Thank you for the help.

wysota
5th October 2007, 16:05
But what exactly is your goal?

TheGrimace
5th October 2007, 16:30
I am creating a thread pool to handle file processing. I get the file names from multiple threads of ExampleOne. These file names are held in a queue in MiddleObject until a signal is received from ExampleTwo (of which there might be many objects) This ExampleTwo object will then process the file and when its done ask for another.

My concern is the ExampleTwo signals blocking the ExampleOne signals which populate the queue.

wysota
5th October 2007, 16:41
But what do you need signals for? Isn't it better to have a wait condition so that all threads wait there until there is anything to do? You could have then a single controller object where you could store jobs and start/stop threads.

TheGrimace
5th October 2007, 16:47
I don't think I understand. How do you transfer information across threads if not by signals/slots?

wysota
5th October 2007, 16:52
Through a common variable.

TheGrimace
5th October 2007, 16:55
Ok, Thank You