Re: g_io_channel_win32_new_messages() & WaitForSingleObject()



Tor Lillqvist wrote:
I have never used that service control API, no idea what it is used for even...
oh, just the needlessly complex, 75 step, windows' equivalent to daemon()

But if MSDN says that the returned SERVICE_STATUS_HANDLE actually is a
normal HANDLE and a waitable one even, that can be passed to
WaitForSingleObject() and friends, then it should work to use it as
the "fd" in a GPollFD.
typedef struct {

#if defined (G_OS_WIN32) && GLIB_SIZEOF_VOID_P == 8
 gint64 fd;
#else
 gint           fd;
#endif
 gushort        events;
 gushort        revents
} GPollFD;


ok so on windows fd here is a pointer to a handle, not the rutime lib's lookup table's integer index...
any ideas what the revents mask should be?

Unfortunately I don't actually know or understand the glib main loop
API very well by heart, so I can't say off-hand what you then should
do with such a GPollFD. Pass it to g_source_add_poll(), but for what
GSource? You might need to implement your own GSource type with
relevant callbacks to take care of that handle "firing", and then pass
such a GSource object to g_source_attach()? Sorry...

--tml
typedef struct {

 gboolean (*prepare)  (GSource    *source,
                        gint       *timeout_);
 gboolean (*check)    (GSource    *source);
 gboolean (*dispatch) (GSource    *source,
                        GSourceFunc callback,
                        gpointer    user_data);
 void     (*finalize) (GSource    *source); /* Can be NULL */

 /* For use by g_source_set_closure */
GSourceFunc closure_callback; GSourceDummyMarshal closure_marshal; /* Really is of type GClosureMarshal */
} GSourceFuncs;


Very interesting. So presumably on windows poll() is really something like WaitForMultiple*()? Which would mean what - a prepare that always returns FALSE w/ *timeout_ = 0, and a check that does what it what otherwise do if WaitForSingleObject() returned hot?

I'm going to try somethings...

---
ww.thomasstover.com




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