Re: (*prepare) and (*check) need user_data




Tim Janik <timj@gtk.org> writes:

> hi owen,
> 
> i discovered that for most applications of GSource in conjunction
> with a poll fd, you'd want to add the pollfd right away with the source
> and remove it again, like:
> 
> static void
> destroy_poll_fd (gpointer data)
> {
>   GPollFD *pfd = data;
> 
>   g_main_remove_poll (pfd);
>   g_free (pfd);
> }
> 
> 
>   pfd = g_new0 (GPollFD, 1);
>   pfd->fd = some_fd;
>   pfd->events |= G_IO_IN | G_IO_OUT | G_IO_PRI;
>   g_main_add_poll (pfd, X_PRIORITY);
>   g_source_add (X_PRIORITY, TRUE, &x_funcs, x, pfd, destroy_poll_fd);
> 
> to properly make use of the pollfd in prepare and check, the user_data pointer
> needs to be provided though, this can be achived while keeping binary
> compatibility with 1.2.0.

OK, I don't understand this at all. The user data  pointer
is only used to dispatch the call back to the user..

This should only be done in the dispatch functtion, or
you're breaking the model...

What gives?
                                        Owen

[ Sorry for the short reply - I'm typing over a 
  trans-pacific link... ]



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