Re: Event loop hangup when using TimeoutSource and IdleSource
- From: Robert Pearce <rob bdt-home demon co uk>
- To: gtkmm-list gnome org
- Subject: Re: Event loop hangup when using TimeoutSource and IdleSource
- Date: Thu, 24 Sep 2009 19:37:59 +0100
Hi Jim,
On Thu, 24 Sep 2009 13:31:53 -0400 you wrote:
> I am trying to create a pretty simple gtkmm application. The purpose
> of the application is to display the status of an attached device and
> to also send commands to the device to control it. The device is
> connected to the computer via a serial port and abstracted by a
> library API that I also wrote. My gtkmm application is designed to
> poll the device for various status via one function that gets called
> every 100 ms via a TimeoutSource.
That's not very different from an application I'm developing.
<snip>
> The weird part is that this "loop" of calling the updateEMSStatus()
> function via the TimeoutSource hangs randomly. It sometimes will hang
> after one cycle through (meaning through every status get request that
> fires in 1 second, 2 seconds, 5 seconds, etc)), and sometimes it'll do
> several cycles through with the timer returning hundreds of times.
I seem to recall having similar problems early on, but I can't remember the details.
> It
> doesn't seem to get stuck in any of my functions, it seems to be the
> Glib event loop that is getting stuck because my GUI becomes
> completely unresponsive. Any thoughts?
Well one thought is that that is an unsafe deduction. The glib event loop is single-threaded and needs everything it calls to return in a timely manner. If one of your functions hangs, whether a command sender or a callback, the result will be to lock up the glib event loop.
> Am I not using the Idlesource
> in a proper manner?
Possibly, but your code snippet didn't look wrong.
> Is this a resource leak somehow?
Unlikely - it's too quick
> How would I go
> about debugging where in the Glib event loop it might be hanging at?
>
With a debugger? Or possibly by scattering a few "entering this", "leaving that" debug messages around.
How are you handling the returned serial data? Are you polling? Calling select? Using read? Using a separate thread? Relying on glib via a Glib::IOChannel (which is the method I use)?
Rob
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]