Re: Problem with GSource and polling
Hey, On Sat, 20 Nov 2010 12:01:47 +0100 Jaroslav Šmíd wrote: > Perhaps he wrote himself some kind of kernel module which provides > pollable file descriptor ... Yep, exactly. > On Sat, Nov 20, 2010 at 9:57 AM, Ardhan Madras wrote: > > Hi Jannis, > > > > I'm sorry but what `kernel module' you are talkin' about?, > > is it the application's module? > > > > Ardhan, > > > > > > --- jan...@xfce.org wrote: > > > > From: Jannis Pohlmann > > To: gtk-app-devel-list@gnome.org > > Subject: Re: Problem with GSource and polling > > Date: Thu, 18 Nov 2010 03:53:20 +0100 > > > > Hi again, > > > > On Thu, 18 Nov 2010 02:26:20 +0100 > > Jannis Pohlmann wrote: > > > >> Hi folks, > >> > >> I have a question about using GSource in combinaton with GPollFD. > > > > Nevermind, I forgot to add poll_wait() in the poll() handler of the > > kernel module that created the file descriptor. Now with that added, > > the GLib main loop wakes up on a poll event even if I am not moving > > the mouse cursor around like crazy in my application window. ;) > > > > - Jannis > > > > > > ___ > > gtk-app-devel-list mailing list > > gtk-app-devel-list@gnome.org > > http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > > > > > > > > _ > > Listen to KNAC, Hit the Home page and Tune In Live! ---> > > http://www.knac.com ___ > > gtk-app-devel-list mailing list > > gtk-app-devel-list@gnome.org > > http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > > > > > ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Problem with GSource and polling
Perhaps he wrote himself some kind of kernel module which provides pollable file descriptor ... On Sat, Nov 20, 2010 at 9:57 AM, Ardhan Madras wrote: > Hi Jannis, > > I'm sorry but what `kernel module' you are talkin' about?, is it the > application's module? > > Ardhan, > > > --- jan...@xfce.org wrote: > > From: Jannis Pohlmann > To: gtk-app-devel-list@gnome.org > Subject: Re: Problem with GSource and polling > Date: Thu, 18 Nov 2010 03:53:20 +0100 > > Hi again, > > On Thu, 18 Nov 2010 02:26:20 +0100 > Jannis Pohlmann wrote: > >> Hi folks, >> >> I have a question about using GSource in combinaton with GPollFD. > > Nevermind, I forgot to add poll_wait() in the poll() handler of the > kernel module that created the file descriptor. Now with that added, > the GLib main loop wakes up on a poll event even if I am not moving the > mouse cursor around like crazy in my application window. ;) > > - Jannis > > > ___ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > > > > _ > Listen to KNAC, Hit the Home page and Tune In Live! ---> http://www.knac.com > ___ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > -- Jaroslav Šmíd ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Problem with GSource and polling
Hi Jannis, I'm sorry but what `kernel module' you are talkin' about?, is it the application's module? Ardhan, --- jan...@xfce.org wrote: From: Jannis Pohlmann To: gtk-app-devel-list@gnome.org Subject: Re: Problem with GSource and polling Date: Thu, 18 Nov 2010 03:53:20 +0100 Hi again, On Thu, 18 Nov 2010 02:26:20 +0100 Jannis Pohlmann wrote: > Hi folks, > > I have a question about using GSource in combinaton with GPollFD. Nevermind, I forgot to add poll_wait() in the poll() handler of the kernel module that created the file descriptor. Now with that added, the GLib main loop wakes up on a poll event even if I am not moving the mouse cursor around like crazy in my application window. ;) - Jannis ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list _ Listen to KNAC, Hit the Home page and Tune In Live! ---> http://www.knac.com ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Problem with GSource and polling
Hi again, On Thu, 18 Nov 2010 02:26:20 +0100 Jannis Pohlmann wrote: > Hi folks, > > I have a question about using GSource in combinaton with GPollFD. Nevermind, I forgot to add poll_wait() in the poll() handler of the kernel module that created the file descriptor. Now with that added, the GLib main loop wakes up on a poll event even if I am not moving the mouse cursor around like crazy in my application window. ;) - Jannis ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Problem with GSource and polling
Hi folks, I have a question about using GSource in combinaton with GPollFD. In a simple application I wrote today, I am creating a simple GSource, add GPollFD to it with g_source_add_poll() and then I attach the source to the default main context using g_source_attach(). The prepare function of my custom GSource always returns FALSE, and it sets the timeout to -1, as is suggested for file descriptor sources in the GLib API docs. The check function checks events against revents (I am using a G_IO_IN event condition) and returns TRUE iff revents includes G_IO_IN. Then I have a dispatch function which is not really interesting at the moment. Now I have a file descriptor for which poll() returns 0 for the first five seconds, and POLLIN from then on. What I experienced in my GTK+ app is that there are a few poll() calls at the beginning, so prepare and check are called. G_IO_IN is not set, so no dispatching takes place. But after those initial polls, new ones are only triggered by generating X events (like when moving the mouse around in the application window). As soon as no X events are generated anymore (e.g. I move the mouse cursor out of the window), no polls (and no calls to the prepare and check functions) are happening. If I set the timeout to something like 1000ms in the prepare function, polling will happen at least every 1000ms. Can anyone tell me if this is normal? Is there a way to poll for G_IO_IN and have prepare/checked/dispatch called without having to generate X events by means of user interaction? Somehow I was assuming that GLib would call poll() and go to sleep until there either is an X event causing the main loop to wake up or until poll() returns because the requested condition is met. But somehow polling is stopped and GLib doesn't react on poll events after that. (I know I could use an idle source or force a timeout, but I really want my app to do *nothing* if there is nothing to do; which in this case means to block until there are X or poll events.) Any help would be greatly appreciated. Anyone got an idea? Cheers, Jannis ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list