Re: keep an io_channel from wasting my time?

On Fri, Dec 13, 2002 at 08:48:55PM -0500, Jeff Abrahamson wrote: 
> No, but a variable contains the amount of stuff to write. I was hoping
> the main loop could key off of additional criteria, although it didn't
> look like it could.

Well the main loop can key off about anything (you can write a custom
GSource implementation), but the prebuilt IO watch GSource is 
only keyed off the file descriptor.
> So then the queue_output function would contain code that says
>     if(!output_handler_registered)
>         g_io_add_watch(gout, G_IO_OUT, do_output, mel);
> and the output handler itself would contain code that says
>     if(more_to_write)
>         return 0;
>     return 1;

Yep, those are pretty standard idioms.

Also you might use the source ID (returned from g_io_add_watch())
instead of a boolean, so you can g_source_remove() if you need to.
  if (output_handler_id == 0)
    output_handler_id = g_io_add_watch ();

Most apps have to store the source ID anyhow because when the window
is closed or whatever they might have to remove it.


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