system:serve-event function is the standard way for an application
to wait for something to happen. For example, the Lisp system calls
system:serve-event when it wants input from X or a terminal stream.
The idea behind
system:serve-event is that it knows the appropriate
action to take when any interesting event happens. If an application calls
system:serve-event when it is idle, then any other applications with
pending events can run. This allows several applications to run “at the
same time” without interference, even though there is only one thread of
control. Note that if an application is waiting for input of any kind,
then other applications will get events.
This function waits for an event to happen and then dispatches to
the correct handler function. If specified, timeout is the
number of seconds to wait before timing out. A time out of zero
seconds is legal and causes
system:serve-event to poll for
any events immediately available for processing.
t if it serviced at least
one event, and
nil otherwise. Depending on the application, when
t, you might want to call it
repeatedly with a timeout of zero until it returns
If input is available on any designated file descriptor, then this
calls the appropriate handler function supplied by
Since events for many different applications may arrive
simultaneously, an application waiting for a specific event must
system:serve-event until the desired event happens.
Since programs such as Hemlock call
input, applications usually do not need to call
system:serve-event at all; Hemlock allows other
application’s handlers to run when it goes into an input wait.
This function is similar to
system:serve-event, except it
serves all the pending events rather than just one. It returns
t if it serviced at least one event, and