mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* cont.c: fix to remove Fiber.new until fiber.so is not loaded.
* test/ruby/test_continuation.rb: fix to use resume. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
71e6011d63
commit
d55c0f5382
3 changed files with 23 additions and 11 deletions
|
@ -1,3 +1,9 @@
|
|||
Sun Aug 26 12:27:14 2007 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* cont.c: fix to remove Fiber.new until fiber.so is not loaded.
|
||||
|
||||
* test/ruby/test_continuation.rb: fix to use resume.
|
||||
|
||||
Sun Aug 26 06:51:46 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
||||
|
||||
* ext/win32ole/win32ole.c (ole_wc2mb, reg_enum_key): allocate
|
||||
|
|
26
cont.c
26
cont.c
|
@ -471,16 +471,10 @@ rb_cont_call(int argc, VALUE *argv, VALUE contval)
|
|||
|
||||
#define FIBER_VM_STACK_SIZE (4 * 1024)
|
||||
|
||||
VALUE
|
||||
rb_fiber_new(VALUE (*func)(ANYARGS), VALUE obj)
|
||||
{
|
||||
return rb_block_call(rb_cFiber, rb_intern("new"), 0, 0, func, obj);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_fiber_s_new(VALUE self)
|
||||
fiber_alloc(VALUE klass, VALUE proc)
|
||||
{
|
||||
rb_context_t *cont = cont_new(self);
|
||||
rb_context_t *cont = cont_new(klass);
|
||||
VALUE contval = cont->self;
|
||||
rb_thread_t *th = &cont->saved_thread;
|
||||
|
||||
|
@ -507,13 +501,25 @@ rb_fiber_s_new(VALUE self)
|
|||
th->cfp->block_iseq = 0;
|
||||
th->tag = 0;
|
||||
|
||||
th->first_proc = rb_block_proc();
|
||||
th->first_proc = proc;
|
||||
|
||||
MEMCPY(&cont->jmpbuf, &th->root_jmpbuf, rb_jmpbuf_t, 1);
|
||||
|
||||
return contval;
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_fiber_new(VALUE (*func)(ANYARGS), VALUE obj)
|
||||
{
|
||||
return fiber_alloc(rb_cFiber, rb_proc_new(func, obj));
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_fiber_s_new(VALUE self)
|
||||
{
|
||||
return fiber_alloc(self, rb_block_proc());
|
||||
}
|
||||
|
||||
static VALUE
|
||||
return_fiber(void)
|
||||
{
|
||||
|
@ -725,7 +731,6 @@ Init_Cont(void)
|
|||
{
|
||||
rb_cFiber = rb_define_class("Fiber", rb_cObject);
|
||||
rb_undef_alloc_func(rb_cFiber);
|
||||
rb_define_singleton_method(rb_cFiber, "new", rb_fiber_s_new, 0);
|
||||
rb_eFiberError = rb_define_class("FiberError", rb_eStandardError);
|
||||
}
|
||||
|
||||
|
@ -743,6 +748,7 @@ Init_Continuation_body(void)
|
|||
void
|
||||
Init_Fiber_body(void)
|
||||
{
|
||||
rb_define_singleton_method(rb_cFiber, "new", rb_fiber_s_new, 0);
|
||||
rb_define_method(rb_cFiber, "resume", rb_fiber_m_resume, -1);
|
||||
rb_define_method(rb_cFiber, "transfer", rb_fiber_m_transfer, -1);
|
||||
rb_define_method(rb_cFiber, "alive?", rb_fiber_alive_p, 0);
|
||||
|
|
|
@ -46,7 +46,7 @@ class TestContinuation < Test::Unit::TestCase
|
|||
c = nil
|
||||
Fiber.new do
|
||||
callcc {|c2| c = c2 }
|
||||
end.yield
|
||||
end.resume
|
||||
c.call
|
||||
}
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue