From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: gerd.moellmann@t-online.de (Gerd Moellmann) Newsgroups: gmane.emacs.devel Subject: Re: signal handling bogosities Date: 20 Dec 2002 11:25:41 +0100 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <86smwt9eca.fsf@gerd.free-bsd.org> References: <20021219140425.GB28566@gnu.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1040380146 19869 80.91.224.249 (20 Dec 2002 10:29:06 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 20 Dec 2002 10:29:06 +0000 (UTC) Cc: emacs-devel@gnu.org Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18PKOv-0005AK-00 for ; Fri, 20 Dec 2002 11:29:05 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 18PKQT-0006jY-00 for ; Fri, 20 Dec 2002 11:30:42 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18PKMQ-00020T-04 for emacs-devel@quimby.gnus.org; Fri, 20 Dec 2002 05:26:30 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 18PKM6-0001zf-00 for emacs-devel@gnu.org; Fri, 20 Dec 2002 05:26:10 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18PKM5-0001zF-00 for emacs-devel@gnu.org; Fri, 20 Dec 2002 05:26:10 -0500 Original-Received: from mailout04.sul.t-online.com ([194.25.134.18]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18PKM3-0001yv-00; Fri, 20 Dec 2002 05:26:07 -0500 Original-Received: from fwd00.sul.t-online.de by mailout04.sul.t-online.com with smtp id 18PKM1-0000P1-08; Fri, 20 Dec 2002 11:26:05 +0100 Original-Received: from gerd.free-bsd.org (520015515780-0001@[217.230.108.13]) by fwd00.sul.t-online.com with esmtp id 18PKLk-0CjTPcC; Fri, 20 Dec 2002 11:25:48 +0100 Original-Received: from gerd.free-bsd.org (localhost [127.0.0.1]) by gerd.free-bsd.org (8.12.6/8.12.6) with ESMTP id gBKAPkhJ000281; Fri, 20 Dec 2002 11:25:46 +0100 (CET) (envelope-from gerd.moellmann@t-online.de) Original-Received: (from gerd@localhost) by gerd.free-bsd.org (8.12.6/8.12.6/Submit) id gBKAPfsQ000278; Fri, 20 Dec 2002 11:25:41 +0100 (CET) X-Authentication-Warning: gerd.free-bsd.org: gerd set sender to gerd.moellmann@t-online.de using -f Original-To: Miles Bader In-Reply-To: Original-Lines: 47 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 X-Sender: 520015515780-0001@t-dialin.net X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Emacs development discussions. List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:10301 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:10301 Miles Bader 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.