summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog2
-rw-r--r--eval.c2
-rw-r--r--ext/tcltklib/tcltklib.c14
-rw-r--r--lib/tk.rb11
-rw-r--r--sample/tkline.rb1
5 files changed, 11 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index bfead7e5ed..4187c0612e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
Thu Apr 16 16:52:01 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/tk.rb: thread support (experimental - maybe slow).
+
* eval.c (rb_longjmp): trace event on exception in raising
context, just before raising exception.
diff --git a/eval.c b/eval.c
index ede12a9a24..e2905deb01 100644
--- a/eval.c
+++ b/eval.c
@@ -3520,7 +3520,7 @@ rb_call(klass, recv, mid, argc, argv, scope)
VALUE *argv; /* OK */
int scope;
{
- NODE *body; /* OK */
+ NODE *body; /* OK */
int noex;
ID id = mid;
struct cache_entry *ent;
diff --git a/ext/tcltklib/tcltklib.c b/ext/tcltklib/tcltklib.c
index 6bebb88f9b..aa2cf71be0 100644
--- a/ext/tcltklib/tcltklib.c
+++ b/ext/tcltklib/tcltklib.c
@@ -33,23 +33,13 @@ int *tclDummyMathPtr = (int *) matherr;
/*---- module TclTkLib ----*/
-static VALUE thread_safe = Qnil;
-
/* execute Tk_MainLoop */
static VALUE
lib_mainloop(VALUE self)
{
- int old_trapflg;
- int flags = RTEST(thread_safe)?TCL_DONT_WAIT:0;
-
DUMP1("start Tk_Mainloop");
while (Tk_GetNumMainWindows() > 0) {
- old_trapflg = trap_immediate;
- trap_immediate = 1;
- Tcl_DoOneEvent(flags);
- trap_immediate = old_trapflg;
- CHECK_INTS;
- flags = (thread_safe == 0 || thread_safe == Qnil)?0:TCL_DONT_WAIT;
+ Tcl_DoOneEvent(0);
}
DUMP1("stop Tk_Mainloop");
@@ -210,8 +200,6 @@ void Init_tcltklib()
/* from Tk_Main() */
DUMP1("Tcl_FindExecutable");
Tcl_FindExecutable(RSTRING(rb_argv0)->ptr);
-
- rb_define_variable("$tk_thread_safe", &thread_safe);
}
/* eof */
diff --git a/lib/tk.rb b/lib/tk.rb
index b932696290..b10274100d 100644
--- a/lib/tk.rb
+++ b/lib/tk.rb
@@ -268,6 +268,13 @@ module TkCore
end
def mainloop
+ if defined?(Thread)
+ INTERP._eval("proc rb_after {} {
+ ruby {Thread.pass};
+ after 200 rb_after
+ }")
+ INTERP._eval("rb_after")
+ end
TclTkLib.mainloop
end
@@ -317,10 +324,6 @@ module Tk
tk_call 'bell'
end
- def mainloop
- TclTkLib.mainloop
- end
-
module Scrollable
def xscrollcommand(cmd=Proc.new)
configure_cmd 'xscrollcommand', cmd
diff --git a/sample/tkline.rb b/sample/tkline.rb
index 63d763a680..2406b0749f 100644
--- a/sample/tkline.rb
+++ b/sample/tkline.rb
@@ -1,5 +1,4 @@
-$tk_thread_safe = TRUE
require "tkclass"
$tkline_init = FALSE