[前][次][番号順一覧][スレッド一覧]

ruby-changes:1787

From: ko1@a...
Date: 26 Aug 2007 12:31:33 +0900
Subject: [ruby-changes:1787] ko1 - Ruby:r13278 (trunk): * cont.c: fix to remove Fiber.new until fiber.so is not loaded.

ko1	2007-08-26 12:31:20 +0900 (Sun, 26 Aug 2007)

  New Revision: 13278

  Modified files:
    trunk/ChangeLog
    trunk/cont.c
    trunk/test/ruby/test_continuation.rb

  Log:
    * cont.c: fix to remove Fiber.new until fiber.so is not loaded.
    * test/ruby/test_continuation.rb: fix to use resume.
    


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/cont.c?r1=13278&r2=13277
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=13278&r2=13277
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_continuation.rb?r1=13278&r2=13277

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 13277)
+++ ChangeLog	(revision 13278)
@@ -1,3 +1,9 @@
+Sun Aug 26 12:27:14 2007  Koichi Sasada  <ko1@a...>
+
+	* 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@n...>
 
 	* ext/win32ole/win32ole.c (ole_wc2mb, reg_enum_key): allocate 
Index: cont.c
===================================================================
--- cont.c	(revision 13277)
+++ cont.c	(revision 13278)
@@ -471,16 +471,10 @@
 
 #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,14 +501,26 @@
     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)
 {
     rb_context_t *cont;
@@ -725,7 +731,6 @@
 {
     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 @@
 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);
Index: test/ruby/test_continuation.rb
===================================================================
--- test/ruby/test_continuation.rb	(revision 13277)
+++ test/ruby/test_continuation.rb	(revision 13278)
@@ -46,7 +46,7 @@
       c = nil
       Fiber.new do
         callcc {|c2| c = c2 }
-      end.yield
+      end.resume
       c.call
     }
   end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml

[前][次][番号順一覧][スレッド一覧]