Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!hp-pcd!hpfcso!stroyan From: stroyan@hpfcso.FC.HP.COM (Mike Stroyan) Newsgroups: comp.sys.hp Subject: Re: Interrupt driven X event loop? Message-ID: <7370341@hpfcso.FC.HP.COM> Date: 19 Mar 91 02:17:29 GMT References: <395@esl.ESL.COM> Organization: Hewlett-Packard, Fort Collins, CO, USA Lines: 32 > -- x event loop > begin > set_up_socket_for_async_notification; -- via SIGIO > loop > if not event_pending > then > suspend_until_data_on_socket; > -- does not block process or poll, but does block > -- ada task so other ada tasks can run. > end if; > get_next_event; > process_event; > end loop; > end; You need to change- get_next_event; process_event; to while (XPending(display)) { get_next_event; process_event; } The Xlib library will read large amounts from the socket at one time. This improves performance by reducing the number of read calls. It also means that multiple events may be read in response to one SIGIO. You may also run into cases where something comes in on the socket that is not an event. The XPending test will avoid blocking in "get_next_event" in that circumstance. Mike Stroyan, mike_stroyan@fc.hp.com