Re: How does gmainloop schedule GSources by priority?

2010-08-15 Thread Havoc Pennington
Hi,

On Sat, Aug 14, 2010 at 9:57 AM, cee1 fykc...@gmail.com wrote:
 I've written a test program, which creating watches for two GIOChannels: one
 for stdin with a low priority, and the other for a named pipe with a high
 priority. Then ran the program with no data written to the named pipe, it
 can still response to input of stdin, which seems like high priority sources
 will not block low priority sources.

Priorities only matter if the sources are both ready. If only stdin
has data and the higher priority one doesn't then the lower priority
would run.

prepare and check both return TRUE if the source is ready (should be
dispatched, i.e. its callback should be invoked). the difference is
that prepare is pre-poll and check is post-poll.

Havoc
___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list


Re: How does gmainloop schedule GSources by priority?

2010-08-14 Thread cee1
Hi, Havoc

2010/8/12 Havoc Pennington h...@pobox.com

 Hi,

 Anyway you are correct, the main loop does not do any fancy scheduling
 where it allocates time slices. Higher priorities simply always win.

 Havoc

I've written a test program, which creating watches for two GIOChannels: one
for stdin with a low priority, and the other for a named pipe with a high
priority. Then ran the program with no data written to the named pipe, it
can still response to input of stdin, which seems like high priority sources
will not block low priority sources.

I go though the code of g_io_unix_prepare, it doen't simply return true. It
seems that when creating a new type of GSource, I should take care of the
*prepare* method, to prevent a very high priority source of this new type
blocking other sources?



-- 
Regards,

- cee1
___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list


Re: How does gmainloop schedule GSources by priority?

2010-08-12 Thread Havoc Pennington
Hi,

On Wed, Aug 11, 2010 at 10:02 PM, cee1 fykc...@gmail.com wrote:
 So if I have a IOChannel watch source with a high priority, and then attach
 an idle source, the idle source will have no change to be scheduled?

An idle source will never be scheduled while any higher-priority
source is ready. (that's why it's called idle it runs when the loop
is idle - not doing anything else. though really it's somewhat of a
misnomer because really an idle source is a run immediately and
always source that happens to default to a low priority; you can set
a higher priority on it and then it won't wait for idleness.)

Anyway you are correct, the main loop does not do any fancy scheduling
where it allocates time slices. Higher priorities simply always win.

Havoc
___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list