[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

10.1 IO Loop

StumpWM’s internal loop is implemented by a generic multiplexing I/O loop for listening to I/O events from multiple sources. The model is as follows:

An I/O multiplexer is represented as an object, with which I/O channels can be registered to be monitored for events when the I/O loop runs. An I/O channel is any object for which the generic functions IO-CHANNEL-IOPORT, IO-CHANNEL-EVENTS and IO-CHANNEL-HANDLE are implemented.

IO-CHANNEL-IOPORT, given an I/O multiplexer and an I/O channel, should return the underlying system I/O facility that the channel operates on. The actual objects used to represent an I/O facility depends on the Lisp implementation, operating system and the specific I/O loop implementation, but, for example, on Unix implementations they will likely be numeric file descriptors. The I/O loop implementation implements IO-CHANNEL-IOPORT methods for the facilities it understands (such as FD-STREAMs on SBCL), so user-implemented channels should simply call IO-CHANNEL-IOPORT recursively on whatever it operates on.

IO-CHANNEL-EVENTS, given an I/O channel, should return a list of the events that the channel is interested in. See the documentation for IO-CHANNEL-EVENTS for further details.

The I/O loop guarantees that it will check what events a channel is interested in when it is first registered, and also at any time the channel has been notified of an event. If the channel changes its mind at any other point in time, it should use the IO-LOOP-UPDATE function to notify the I/O loop of such changes. The I/O loop may very well also update spuriously at other times, but such updates are not guaranteed.

IO-CHANNEL-HANDLE is called by the I/O loop to notify a channel of an event.

An I/O multiplexer is created with a MAKE-INSTANCE call on the class of the desired multiplexer implementation. If the code using the multiplexer has no certain preferences on an implementation (which should be the usual case), the variable *DEFAULT-IO-LOOP* points to a class that should be generally optimal given the current Lisp implementation and operating system.

Given a multiplexer, channels can be registered with it using IO-LOOP-ADD, unregistered with IO-LOOP-REMOVE, and updated with IO-LOOP-UPDATE (as described above). Call IO-LOOP on the multiplexer to actually run it.

Variable: *default-io-loop*

nil

Variable: *current-io-loop*

nil

Variable: *current-io-channel*

nil

Function: io-channel-ioport io-loop channel

nil

@ io-channel-ioport

Function: io-channel-events channel

nil

@ io-channel-events

Function: io-channel-handle channel event &key

nil

@ io-channel-handle @ io-loop-add @ io-loop-remove @ io-loop-update @ io-loop


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on January 28, 2024 using texi2html 1.82.