Re: io watch callback and condition modification
- From: Szalai Ferenc <szferi angel elte hu>
- To: gtk-list gnome org
- Subject: Re: io watch callback and condition modification
- Date: 13 Apr 2002 11:18:55 +0200
Discussion myself :)
> It creates an io watch in the default main loop context using
> g_io_add_watch_full function with an condition (G_IO_IN | G_IO_ERR |
> G_IO_HUP) and callback function (do_read).
> The question is: How can I change normally the callback function (eg.:
> do_write) and condition (eg.: G_IO_OUT | G_IO_ERR) without removeing and
> reattaching the watch
> form the context?
There is one problem why this can't do:
In giounix.c and giowin32.c module there is a GIO[Unix,Win32]Watch
structure which have a condition element. In g_main_context_check the
source's check function evaluate the following expression:
((poll_condition | buffer_condition) & watch->condition)
Where the watch->condition can't modified from outside of glib. But it
is necessary in case described above.
So I suggest two possible modification to solve this problem:
1. Change watch->condition in g_io_[unix,win32]_[check,
prepare,dispatch, finalize] function to watch->pollfd.events
2. Or EXTEND the glib API with eg: g_io_set_watch_condition function
which modify the appropriate pollfd.events and watch->condition
variables to a requested value.
(I have a patch for secound one.)
I think this feature will useful in any cases when you design a server
application using glib.
I waiting for any comment.
Thanks,
Ferenc Szalai
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]