[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: signal handling bogosities
From: |
Gerd Moellmann |
Subject: |
Re: signal handling bogosities |
Date: |
20 Dec 2002 11:25:41 +0100 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 |
Miles Bader <address@hidden> writes:
> Perhaps I'm confused, but why can't the existing code that runs from the
> signal handler just be called from the event loop instead, at least as
> an easy first-step?
>
> For instance, if the signal handler currently looks like:
>
> void signal_handler (...)
> {
> if (some_test)
> do_mouse_stuff (mouse_info);
> else if (some_other_test)
> do_exposure_stuff (other info);
> }
>
> change it to be like:
>
> void signal_handler (...)
> {
> if (some_test)
> queue_mouse_event (mouse_info);
> else if (some_other_test)
> queue_exposure_event (exposure_info);
> }
>
> void event_loop_function (...)
> {
> while (event in event loop)
> {
> ...
> if (event->type == mouse_event)
> do_mouse_stuff (event->mouse_info)
> else if (event->type == exposure_event)
> do_exposure_stuff (event->exposure_info)
> ...
> }
> }
>
> In other words, re-use as much of the existing code as possible, but
> change the place where it's called.
What I was thinking about as "event loop" is a toolkit's event loop,
like XtAppMainLoop etc. for Xt, for instance.
I must admit that I never thought about using a home-brewed event
loop, so I can't say much about what that entails, sorry.