1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* cont.c: Thread local storage should be fiber local.

* bootstraptest/test_knownbug.rb, test/ruby/test_fiber.rb:
  move a fixed test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13555 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2007-09-28 19:04:45 +00:00
parent 4dc8ff965b
commit 534d057e58
5 changed files with 44 additions and 31 deletions

View file

@ -1,3 +1,10 @@
Sat Sep 29 03:53:26 2007 Koichi Sasada <ko1@atdot.net>
* cont.c: Thread local storage should be fiber local.
* bootstraptest/test_knownbug.rb, test/ruby/test_fiber.rb:
move a fixed test.
Fri Sep 28 23:15:31 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* insnhelper.ci (vm_call_method): allow send! to call protected

View file

@ -13,31 +13,3 @@ assert_finish 1, %q{
w.write "a"
}, '[ruby-dev:31866]'
assert_equal "[[nil, 1, 3, 3, 1, nil, nil], [nil, 2, 2, nil]]", %q{
def tvar(var, val)
old = Thread.current[var]
begin
Thread.current[var] = val
yield
ensure
Thread.current[var] = old
end
end
ary1 = []
ary2 = []
fb = Fiber.new {
ary2 << Thread.current[:v]; tvar(:v, 2) {
ary2 << Thread.current[:v]; Fiber.yield
ary2 << Thread.current[:v]; }
ary2 << Thread.current[:v]; Fiber.yield
ary2 << Thread.current[:v]
}
ary1 << Thread.current[:v]; tvar(:v,1) {
ary1 << Thread.current[:v]; tvar(:v,3) {
ary1 << Thread.current[:v]; fb.resume
ary1 << Thread.current[:v]; }
ary1 << Thread.current[:v]; }
ary1 << Thread.current[:v]; fb.resume
ary1 << Thread.current[:v];
[ary1, ary2]
}

5
cont.c
View file

@ -86,6 +86,9 @@ cont_free(void *ptr)
RUBY_FREE_UNLESS_NULL(cont->machine_register_stack);
#endif
RUBY_FREE_UNLESS_NULL(cont->vm_stack);
if (cont->saved_thread.local_storage) {
st_free_table(cont->saved_thread.local_storage);
}
ruby_xfree(ptr);
}
RUBY_FREE_LEAVE("cont");
@ -205,6 +208,7 @@ cont_restore_1(rb_context_t *cont)
/* fiber */
th->stack = sth->stack;
th->stack_size = sth->stack_size;
th->local_storage = sth->local_storage;
th->fiber = cont->self;
}
else {
@ -500,6 +504,7 @@ fiber_alloc(VALUE klass, VALUE proc)
th->cfp->proc = 0;
th->cfp->block_iseq = 0;
th->tag = 0;
th->local_storage = st_init_numtable();
th->first_proc = proc;

View file

@ -131,5 +131,34 @@ class TestFiber < Test::Unit::TestCase
assert_equal(:ok, f1.transfer)
assert_equal([:baz], ary)
end
def test_tls
#
def tvar(var, val)
old = Thread.current[var]
begin
Thread.current[var] = val
yield
ensure
Thread.current[var] = old
end
end
fb = Fiber.new {
assert_equal(nil, Thread.current[:v]); tvar(:v, :x) {
assert_equal(:x, Thread.current[:v]); Fiber.yield
assert_equal(:x, Thread.current[:v]); }
assert_equal(nil, Thread.current[:v]); Fiber.yield
raise # unreachable
}
assert_equal(nil, Thread.current[:v]); tvar(:v,1) {
assert_equal(1, Thread.current[:v]); tvar(:v,3) {
assert_equal(3, Thread.current[:v]); fb.resume
assert_equal(3, Thread.current[:v]); }
assert_equal(1, Thread.current[:v]); }
assert_equal(nil, Thread.current[:v]); fb.resume
assert_equal(nil, Thread.current[:v]);
end
end

View file

@ -1,7 +1,7 @@
#define RUBY_VERSION "1.9.0"
#define RUBY_RELEASE_DATE "2007-09-28"
#define RUBY_RELEASE_DATE "2007-09-29"
#define RUBY_VERSION_CODE 190
#define RUBY_RELEASE_CODE 20070928
#define RUBY_RELEASE_CODE 20070929
#define RUBY_PATCHLEVEL 0
#define RUBY_VERSION_MAJOR 1
@ -9,7 +9,7 @@
#define RUBY_VERSION_TEENY 0
#define RUBY_RELEASE_YEAR 2007
#define RUBY_RELEASE_MONTH 9
#define RUBY_RELEASE_DAY 28
#define RUBY_RELEASE_DAY 29
#ifdef RUBY_EXTERN
RUBY_EXTERN const char ruby_version[];