00001 #ifndef R_EVENTLOOP_H_PKG
00002 #define R_EVENTLOOP_H_PKG
00003
00009 #include "Rinternals.h"
00010
00014 typedef struct _R_EventLoop R_EventLoop;
00015
00022 typedef int (*R_IdleFunc)(void *);
00024 typedef R_IdleFunc R_TimerFunc;
00025
00037 struct _R_EventLoop {
00039 char *name;
00040
00045 void (*init)(int *argc, char ***argv);
00046
00049 void (*exit)();
00050
00055 void (*main)(void);
00056
00061 int (*nonBlockingIteration)();
00062
00066 void (*quit)();
00067
00068
00077 SEXP (*addInput)(int fd, void (*handler)(void *, int, int), void *userData);
00078
00087 SEXP (*addIdle)(R_IdleFunc, void *userData);
00088
00094 SEXP (*addTimer)(int interval, R_TimerFunc, void *userData);
00095
00098 int (*removeInput)(SEXP);
00103 int (*removeIdle)(SEXP);
00105 int (*removeTimer)(SEXP);
00106
00123 void *data;
00124
00127 R_EventLoop *next;
00128
00132 R_EventLoop *prev;
00133 };
00134
00135
00140 extern R_EventLoop *R_eloop;
00141
00142 void R_mainLoop();
00143
00144 SEXP R_localAddIdle(R_IdleFunc f, void *userData);
00145
00146
00147 typedef enum {RGTK_CALLBACK, RGTK_TIMER, RGTK_IDLE} RCallbackDataType;
00148
00149 typedef struct {
00150 SEXP function;
00151 SEXP data;
00152 Rboolean useData;
00153
00154 RCallbackDataType type;
00155 } R_CallbackData;
00156
00157
00158 #endif