summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-05-27 19:12:43 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-05-27 19:12:43 +0000
commit57062d91b9bfb1688151cd2393011504fd26f0d8 (patch)
tree586958dc0f4d60d96f50d9a30ebfcc20b88f9d5a /thread.c
parentb69b1af65002e9a70a4f33bafa35593b4618e7a4 (diff)
* 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@12395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/thread.c b/thread.c
index 296e6eb146..d0434d286b 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;