なかだです。

Threadの中でbreakしたとき、常にvalueがfalseになります。

$ ruby -v -e 'p Thread.start{break 10}.value'
ruby 1.8.0 (2003-10-06) [i686-linux]
false

# ついでにvolatile減らし。

* eval.c (rb_thread_start_0): set the value from break.

* eval.c (rb_thread_start_0, rb_thread_raise, rb_callcc): save
  variables across THREAD_SAVE_CONTEXT.

Index: eval.c =================================================================== RCS file: /cvs/ruby/src/ruby/eval.c,v retrieving revision 1.551 diff -u -2 -p -r1.551 eval.c --- eval.c 6 Oct 2003 17:59:52 -0000 1.551 +++ eval.c 8 Oct 2003 13:36:10 -0000 @@ -8200,5 +8200,5 @@ rb_thread_check(data) } -static VALUE rb_thread_raise _((int, VALUE*, volatile rb_thread_t)); +static VALUE rb_thread_raise _((int, VALUE*, rb_thread_t)); static int th_raise_argc; @@ -9402,12 +9402,11 @@ rb_thread_stop_timer() static VALUE -rb_thread_start_0(fn, arg, th_arg) +rb_thread_start_0(fn, arg, th) VALUE (*fn)(); void *arg; - rb_thread_t th_arg; + rb_thread_t th; { - volatile rb_thread_t th = th_arg; - volatile VALUE thread = th->thread; - volatile struct BLOCK* saved_block = 0; + volatile rb_thread_t th_save = th; + struct BLOCK *volatile saved_block = 0, *block; enum thread_status status; int state; @@ -9432,5 +9431,5 @@ rb_thread_start_0(fn, arg, th_arg) if (THREAD_SAVE_CONTEXT(curr_thread)) { - return thread; + return th_save->thread; } @@ -9461,4 +9460,8 @@ rb_thread_start_0(fn, arg, th_arg) } } + else if (TAG_DST()) { + th->result = prot_tag->retval; + } + th = th_save; POP_TAG(); status = th->status; @@ -9467,10 +9470,10 @@ rb_thread_start_0(fn, arg, th_arg) rb_thread_remove(th); - while (saved_block) { - volatile struct BLOCK *tmp = saved_block; + for (block = saved_block; block;) { + struct BLOCK *tmp = block; if (tmp->frame.argc > 0) free(tmp->frame.argv); - saved_block = tmp->prev; + block = tmp->prev; free((void*)tmp); } @@ -9765,6 +9768,8 @@ rb_thread_raise(argc, argv, th) int argc; VALUE *argv; - volatile rb_thread_t th; + rb_thread_t th; { + volatile rb_thread_t th_save = th; + if (rb_thread_dead(th)) return Qnil; if (curr_thread == th) { @@ -9774,5 +9779,5 @@ rb_thread_raise(argc, argv, th) if (!rb_thread_dead(curr_thread)) { if (THREAD_SAVE_CONTEXT(curr_thread)) { - return th->thread; + return th_save->thread; } } @@ -9937,5 +9942,6 @@ rb_callcc(self) { volatile VALUE cont; - volatile rb_thread_t th; + rb_thread_t th; + volatile rb_thread_t th_save; struct tag *tag; struct RVarmap *vars; @@ -9955,6 +9961,7 @@ rb_callcc(self) } + th_save = th; if (THREAD_SAVE_CONTEXT(th)) { - return th->result; + return th_save->result; } else {