GSource and file descriptors



	Ok, so I'm trying to poll some file descriptors, and I'm finding
Gsource to be a bit of a pain.  I'm using HEAD.  The GSourceFuncs have
removed the source_data parameters etc.  This means that the GPollFD
structure involved in a call is not passed to the prepare/check/dispatch
functions.  Here's what I see:

Option 1:
	Make your GPollFDs global.  Have a GSourceFuncs for each FD, and
set it up.  This includes global data and lots of functions (three per
fd).

Option 2:
	Make GPollFDs global.  Have one GSourceFuncs that runs through
each GPollFD checking revents and dispatching callbacks.  This includes
global data, but a smaller number of functions.

Option 3:
	Access source->pollfds.  Run through each one and check revents,
dispatching whatever.  This removes the global data need, but returns
with direct structure access, which is also ugly (outside of glib
itself).

	In all these cases, the initialization steps required to simply
poll a file descriptor are large.  I'm amazed there isn't a default
GSource for descriptors like there exists for timeouts and idles.
Would a patch for 2.0 be accepted that implements something like the
following:

typedef gboolean (*GPollFunc)(GPollFD *pollfd, gpointer user_data);
gint g_poll_add(GPollFD *pollfd,
                GPollFunc callback,
                gpointer user_data);

with similar semantics to timeouts and idles (ie, return FALSE removes
the source)?  I suspect that most folks would prefer this call to
building their own GSource for every fd.  File descriptors exist
alongside timeouts and idles as the common cases.  The flexibility of
GSource is great for folks with new sources, but that shouldn't hurt the
normal user.

Joel

-- 

"I'm so tired of being tired,
 Sure as night will follow day.
 Most things I worry about
 Never happen anyway."

			http://www.jlbec.org/
			jlbec evilplan org




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]