summaryrefslogtreecommitdiff
path: root/ext/tcltklib
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-06-24 04:24:09 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-06-24 04:24:09 +0000
commit031d2e84df58ed54948671931544c41cf32da1ca (patch)
tree1118362b178f55bf14d142752b8d61976191b991 /ext/tcltklib
parent37bcc42c983987ec504efd9556f0cb884f0b424d (diff)
990624
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_3@490 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tcltklib')
-rw-r--r--ext/tcltklib/tcltklib.c59
1 files changed, 37 insertions, 22 deletions
diff --git a/ext/tcltklib/tcltklib.c b/ext/tcltklib/tcltklib.c
index 6652b9409aa..352b0778db8 100644
--- a/ext/tcltklib/tcltklib.c
+++ b/ext/tcltklib/tcltklib.c
@@ -44,8 +44,6 @@ int *tclDummyMathPtr = (int *) matherr;
/*---- module TclTkLib ----*/
-static VALUE main_thread;
-
struct invoke_queue {
int argc;
VALUE *argv;
@@ -55,35 +53,52 @@ struct invoke_queue {
VALUE thread;
struct invoke_queue *next;
};
-
+
static struct invoke_queue *iqueue;
+static VALUE main_thread;
-/* execute Tk_MainLoop */
-static VALUE
-lib_mainloop(self)
- VALUE self;
+/* Tk_ThreadTimer */
+static Tcl_TimerToken timer_token;
+
+/* timer callback */
+static void
+_timer_for_tcl(clientData)
+ ClientData clientData;
{
struct invoke_queue *q, *tmp;
VALUE thread;
- DUMP1("start Tk_Mainloop");
- while (Tk_GetNumMainWindows() > 0) {
- Tcl_DoOneEvent(TCL_DONT_WAIT);
- CHECK_INTS;
- q = iqueue;
- while (q) {
- tmp = q;
- q = q->next;
- if (!tmp->done) {
- tmp->done = 1;
- tmp->result = ip_invoke_real(tmp->argc, tmp->argv, tmp->obj);
- thread = tmp->thread;
- tmp = tmp->next;
- rb_thread_run(thread);
- }
+ Tk_DeleteTimerHandler(timer_token);
+ timer_token = Tk_CreateTimerHandler(100, _timer_for_tcl,
+ (ClientData)0);
+
+ CHECK_INTS;
+ q = iqueue;
+ while (q) {
+ tmp = q;
+ q = q->next;
+ if (!tmp->done) {
+ tmp->done = 1;
+ tmp->result = ip_invoke_real(tmp->argc, tmp->argv, tmp->obj);
+ thread = tmp->thread;
+ tmp = tmp->next;
+ rb_thread_run(thread);
}
}
+ rb_thread_schedule();
+}
+
+/* execute Tk_MainLoop */
+static VALUE
+lib_mainloop(self)
+ VALUE self;
+{
+ timer_token = Tk_CreateTimerHandler(100, _timer_for_tcl,
+ (ClientData)0);
+ DUMP1("start Tk_Mainloop");
+ Tk_MainLoop();
DUMP1("stop Tk_Mainloop");
+ Tk_DeleteTimerHandler(timer_token);
return Qnil;
}