Main Page   Data Structures   File List   Data Fields   Globals  

_R_EventLoop Struct Reference

#include <Reventloop.h>


Data Fields

char * name
void(* init )(int *argc, char ***argv)
void(* exit )()
void(* main )(void)
int(* nonBlockingIteration )()
void(* quit )()
SEXP(* addInput )(int fd, void(*handler)(void *, int, int), void *userData)
SEXP(* addIdle )(R_IdleFunc, void *userData)
SEXP(* addTimer )(int interval, R_TimerFunc, void *userData)
int(* removeInput )(SEXP)
int(* removeIdle )(SEXP)
int(* removeTimer )(SEXP)
void * data
R_EventLoopnext
R_EventLoopprev


Detailed Description

This is the main data structure for representing an internal R event loop. It has methods for running the event loop; processing an individual event; registering and unregistering input sources, idle and timer actions;

We can maintain a linked list of these event loop structures.

What about releasing user-level data objects?


Field Documentation

SEXP(* _R_EventLoop::addIdle)(R_IdleFunc, void *userData)
 

register a C routine that is to be invoked whenever there are no events pending and the event loop has "nothing" to do. These are essentially background events that should return control very rapidly. S functions can be used by specifying a suitable handler that treates the userData argument as an S function and invokes it.

SEXP(* _R_EventLoop::addInput)(int fd, void (*handler)(void *, int, int), void *userData)
 

register an input source (identified by its file descriptor) and an event handler for it which is called any time there is input detected on it. The userData field allow one to specify arbitrary data that is passed to the handler when it is called and used to parameterize the actions of that handler. S functions can be used by specifying a suitable handler that treates the userData argument as an S function and invokes it.

SEXP(* _R_EventLoop::addTimer)(int interval, R_TimerFunc, void *userData)
 

register a C routine that is to be called after interval milli-seconds. These are timed actions. The userData argument is passed to the routine when it is invoked and used to parameterize its actions.

void* _R_EventLoop::data
 

a field for storing data used by the event loop to perform its duties. This can be used in a total event-loop implementation specific manner. Unfortunately, without C++ classes, it is hard to get at this variable without assuming it is in the active event loop (R_eloop). This does allow us to place instance-specific data within each instance of the same event loop structure. For example, if we have two copies of the Tcl event loop, we can store different data there. As each one is made the active event loop, the methods can find their specific instance of the data.

If we wanted to make the data available to the methods without assuming the event loop is the active one, we need to add an argument to each method. This may be important if we want to run an event loop as a sub-event loop (e.g. nest Gtk inside Tcl) using these structures and not swap it onto the R_eloop variable.

void(* _R_EventLoop::exit)()
 

called when the event loop is terminated. This is the parallel function to init

void(* _R_EventLoop::init)(int *argc, char ***argv)
 

a routine that is called each time the event loop is started. It can be used to initialize a toolkit; perform initialization for running the event loop such as maintaining a stack of active instances.

void(* _R_EventLoop::main)(void)
 

the method to run the endless event loop that must be explicitly terminated by calling quit or exiting the process.

char* _R_EventLoop::name
 

a simple, user-comprehensible name for this event loop.

R_EventLoop* _R_EventLoop::next
 

the next event loop in the linked list/stack. This is different from a nested event loop call which is handled by the C stack, not this stack.

int(* _R_EventLoop::nonBlockingIteration)()
 

the method for processing a single event from this event source without blocking if there is no event on the queue.

R_EventLoop* _R_EventLoop::prev
 

the previous event loop structure in the linked list of event structures maintained by R.

void(* _R_EventLoop::quit)()
 

terminate the event loop. See main

int(* _R_EventLoop::removeIdle)(SEXP)
 

unregister a idle/background routine This takes the object returned by addIdle to identify the particular.

int(* _R_EventLoop::removeInput)(SEXP)
 

unregister a handler for an input source. This takes the object returned by addInput

int(* _R_EventLoop::removeTimer)(SEXP)
 

unregister a timer action routine


The documentation for this struct was generated from the following file:
Generated on Wed Oct 9 15:02:03 2002 for REventLoop by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002