Event Loop
The current event loop is hand crafted to recognize input only on
standard input and the single X11 connection used to create all X11
devices. A more general mechanism which allows other X11 connections
(e.g. an embedded XGobi) and general connections or streams would be
useful. It can be made accessible to C-level package developers. The
facilities can be implemented for Unix with relative ease and is
described in the next few paragraphs.
We maintain a "collection" of active file descriptors to which we
listen for activity. Each of these has an associated routine which is
invoked when on which input may arrive
Files affected
- eventloop.h
- sys-std.c
- X11/devX11.c
Changes include
The mechanism in Rstd_ReadConsole() for dispatching
the event handlers. Instead of the switch statement that handles
the X and Stdin activities, we now handle the Stdin case as before
(since this requires arguments (buf and len)) and all other
handlers generically.
devX11.c has a change to R_ProcessEvents() so that it takes
a redundant argument so that it adheres to the function typdef
in EventLoop.h
Additionlly, the X11_Open() registers an input handler
on the first call that establishes the Display and connection
to the X server.
Issues
-
- Updates
- When testing with XGobi, I occassionally notic that the display was
not being updated. The solution is simple. Place the mouse in the
XGobi window to ensure that an event is sent to the queue and select
identifies input as pending.
-
- Test the linked list manipulation (i.e. the get and remove).
-
-
- Build facilities for handling R functions.
-
-
- We could use a hashtable rather than a linked list, but
I don't think it is worth any effort. The number of connections
should be small in general. So lookup time by traversal will be
small.
-
Threads