Next: Using SERVE-EVENT with Unix File Descriptors, Previous: Object Sets, Up: Event Dispatching with SERVE-EVENT [Contents][Index]
The 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.
&optional
timeout ¶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.
system:serve-event
returns t
if it serviced at least
one event, and nil
otherwise. Depending on the application, when
system:serve-event
returns t
, you might want to call it
repeatedly with a timeout of zero until it returns nil
.
If input is available on any designated file descriptor, then this
calls the appropriate handler function supplied by
system:add-fd-handler
.
Since events for many different applications may arrive
simultaneously, an application waiting for a specific event must
loop on system:serve-event
until the desired event happens.
Since programs such as Hemlock call system:serve-event
for
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.
&optional
timeout ¶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 nil
otherwise.
Next: Using SERVE-EVENT with Unix File Descriptors, Previous: Object Sets, Up: Event Dispatching with SERVE-EVENT [Contents][Index]