Path: utzoo!yunexus!ists!helios.physics.utoronto.ca!news-server.csri.toronto.edu!mailrus!uwm.edu!ogicse!decwrl!decwrl!wsl.dec.com!klee From: klee@wsl.dec.com (Ken Lee) Newsgroups: comp.windows.x Subject: Re: Avoiding Event Loops Message-ID: <4581@bacchus.dec.com> Date: 29 May 90 16:40:58 GMT Article-I.D.: bacchus.4581 References: <109658@linus.UUCP> Sender: news@decwrl.dec.com Reply-To: klee@wsl.dec.com Organization: DEC Western Software Laboratory Lines: 24 In article <109658@linus.UUCP>, cookson@helios.mitre.org (Cookson) writes: |> I'm writing a simulation that has a main loop that must be executed |> with preference over the event loop. (Can't hang around and wait for events), |> But I also want a robust handling of user generated events. How can I |> (on a unix machine) run the simulation loop and the event loop in parallel? There are several ways to do this, depending on the form of input from your simulation. On most UNIX systems, Xlib uses select() to wait for events from the server. If your simulation is a separate process, you can select() on both the X server and the simulation process. In effect, this uses the UNIX scheduler to timeshare your user interface process and simulation process. Another alternative is to use one of the multi-threads packages to do this timesharing within one process. You might also do this multi-threading more efficiently yourself, by taking advantage of implementation details. Finally, look into the work, input, and timer proc stuff in the X Toolkit for a few more ideas. Ken Lee DEC Western Software Laboratory, Palo Alto, Calif. Internet: klee@wsl.dec.com uucp: uunet!decwrl!klee