mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* cont.c (rb_fiber_start): clear th->tag and check error to fix
[ruby-dev:30888] and [ruby-dev:30889]. * eval_intern.h: fix rb_fiber_start() prototype. * test/ruby/test_fiber.rb: add tests for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12443 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5f05c269e9
commit
64ffdb4440
4 changed files with 32 additions and 2 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
Wed Jun 6 02:50:53 2007 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
|
* cont.c (rb_fiber_start): clear th->tag and check error to fix
|
||||||
|
[ruby-dev:30888] and [ruby-dev:30889].
|
||||||
|
|
||||||
|
* eval_intern.h: fix rb_fiber_start() prototype.
|
||||||
|
|
||||||
|
* test/ruby/test_fiber.rb: add tests for above.
|
||||||
|
|
||||||
Wed Jun 6 02:40:20 2007 NAKAMURA Usaku <usa@ruby-lang.org>
|
Wed Jun 6 02:40:20 2007 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||||
|
|
||||||
* insnhelper.h, insns.def (DEC_SP): shoudn't use unary minus operator
|
* insnhelper.h, insns.def (DEC_SP): shoudn't use unary minus operator
|
||||||
|
|
4
cont.c
4
cont.c
|
@ -421,6 +421,8 @@ rb_fiber_start(void)
|
||||||
VALUE args;
|
VALUE args;
|
||||||
int state;
|
int state;
|
||||||
|
|
||||||
|
th->tag = 0;
|
||||||
|
|
||||||
TH_PUSH_TAG(th);
|
TH_PUSH_TAG(th);
|
||||||
if ((state = EXEC_TAG()) == 0) {
|
if ((state = EXEC_TAG()) == 0) {
|
||||||
GetContPtr(th->fiber, cont);
|
GetContPtr(th->fiber, cont);
|
||||||
|
@ -436,7 +438,7 @@ rb_fiber_start(void)
|
||||||
TH_POP_TAG();
|
TH_POP_TAG();
|
||||||
|
|
||||||
if (state) {
|
if (state) {
|
||||||
th->thrown_errinfo = th->errinfo;
|
th->thrown_errinfo = th_make_jump_tag_but_local_jump(state, th->errinfo);
|
||||||
th->interrupt_flag = 1;
|
th->interrupt_flag = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,7 @@ char *strrchr _((const char *, const char));
|
||||||
stmt; \
|
stmt; \
|
||||||
} \
|
} \
|
||||||
else { \
|
else { \
|
||||||
rb_fiber_start(th); \
|
rb_fiber_start(); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define TH_PUSH_TAG(th) do { \
|
#define TH_PUSH_TAG(th) do { \
|
||||||
|
@ -193,6 +193,8 @@ int thread_reset_raised(rb_thread_t *th);
|
||||||
VALUE rb_f_eval(int argc, VALUE *argv, VALUE self);
|
VALUE rb_f_eval(int argc, VALUE *argv, VALUE self);
|
||||||
VALUE rb_make_exception _((int argc, VALUE *argv));
|
VALUE rb_make_exception _((int argc, VALUE *argv));
|
||||||
|
|
||||||
|
NORETURN(void rb_fiber_start(void));
|
||||||
|
|
||||||
NORETURN(void rb_raise_jump _((VALUE)));
|
NORETURN(void rb_raise_jump _((VALUE)));
|
||||||
NORETURN(void print_undef _((VALUE, ID)));
|
NORETURN(void print_undef _((VALUE, ID)));
|
||||||
NORETURN(void th_localjump_error(const char *, VALUE, int));
|
NORETURN(void th_localjump_error(const char *, VALUE, int));
|
||||||
|
@ -203,6 +205,7 @@ VALUE th_compile(rb_thread_t *th, VALUE str, VALUE file, VALUE line);
|
||||||
NODE *th_get_cref(rb_thread_t *th, rb_iseq_t *iseq, rb_control_frame_t *cfp);
|
NODE *th_get_cref(rb_thread_t *th, rb_iseq_t *iseq, rb_control_frame_t *cfp);
|
||||||
NODE *th_cref_push(rb_thread_t *th, VALUE, int);
|
NODE *th_cref_push(rb_thread_t *th, VALUE, int);
|
||||||
NODE *th_set_special_cref(rb_thread_t *th, VALUE *lfp, NODE * cref_stack);
|
NODE *th_set_special_cref(rb_thread_t *th, VALUE *lfp, NODE * cref_stack);
|
||||||
|
VALUE th_make_jump_tag_but_local_jump(int state, VALUE val);
|
||||||
|
|
||||||
static rb_control_frame_t *
|
static rb_control_frame_t *
|
||||||
th_get_ruby_level_cfp(rb_thread_t *th, rb_control_frame_t *cfp)
|
th_get_ruby_level_cfp(rb_thread_t *th, rb_control_frame_t *cfp)
|
||||||
|
|
|
@ -69,5 +69,21 @@ class TestFiber < Test::Unit::TestCase
|
||||||
assert_equal(:ok, f1.yield)
|
assert_equal(:ok, f1.yield)
|
||||||
assert_equal([:baz, :bar], ary)
|
assert_equal([:baz, :bar], ary)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_return
|
||||||
|
assert_raise(LocalJumpError){
|
||||||
|
Fiber.new do
|
||||||
|
return
|
||||||
|
end.yield
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_throw
|
||||||
|
assert_raise(RuntimeError){
|
||||||
|
Fiber.new do
|
||||||
|
throw :a
|
||||||
|
end.yield
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue