From e5f3b1a5cc39db25503f1d175fbd0f93c04a85c6 Mon Sep 17 00:00:00 2001 From: ko1 Date: Sun, 27 May 2007 19:12:43 +0000 Subject: * cont.c: support Fiber. Check test/ruby/test_fiber.rb for detail. Fiber is known as "Micro Thread", "Coroutine", and other terms. At this time, only Fiber#pass is supported to change context. I want to know more suitable method name/API for Fiber (... do you know more suitable class name instead of Fiber?) as "suspend/resume", "call", "yield", "start/kick/stop/restart", .... * eval.c, eval_intern.h, thread.c, yarvcore.c, yarvcore.h: ditto. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@12395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- thread.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'thread.c') diff --git a/thread.c b/thread.c index 296e6eb14..d0434d286 100644 --- a/thread.c +++ b/thread.c @@ -298,17 +298,19 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start) TH_PUSH_TAG(th); if ((state = EXEC_TAG()) == 0) { - if (th->first_proc) { - GetProcPtr(th->first_proc, proc); - th->errinfo = Qnil; - th->local_lfp = proc->block.lfp; - th->local_svar = Qnil; - th->value = th_invoke_proc(th, proc, proc->block.self, - RARRAY_LEN(args), RARRAY_PTR(args)); - } - else { - th->value = (*th->first_func)(th->first_func_arg); - } + SAVE_ROOT_JMPBUF(th, { + if (th->first_proc) { + GetProcPtr(th->first_proc, proc); + th->errinfo = Qnil; + th->local_lfp = proc->block.lfp; + th->local_svar = Qnil; + th->value = th_invoke_proc(th, proc, proc->block.self, + RARRAY_LEN(args), RARRAY_PTR(args)); + } + else { + th->value = (*th->first_func)(th->first_func_arg); + } + }); } else { th->value = Qnil; -- cgit