ruby-changes:62918
From: Samuel <ko1@a...>
Date: Mon, 14 Sep 2020 13:44:28 +0900 (JST)
Subject: [ruby-changes:62918] 132453fa52 (master): Rename `Fiber{}` to `Fiber.schedule{}`.
https://git.ruby-lang.org/ruby.git/commit/?id=132453fa52 From 132453fa521cf87693035769031f3501ddc02f4a Mon Sep 17 00:00:00 2001 From: Samuel Williams <samuel.williams@o...> Date: Fri, 21 Aug 2020 00:52:36 +1200 Subject: Rename `Fiber{}` to `Fiber.schedule{}`. diff --git a/cont.c b/cont.c index efff86f..d228107 100644 --- a/cont.c +++ b/cont.c @@ -2554,7 +2554,8 @@ Init_Cont(void) https://github.com/ruby/ruby/blob/trunk/cont.c#L2554 rb_define_method(rb_cFiber, "to_s", fiber_to_s, 0); rb_define_alias(rb_cFiber, "inspect", "to_s"); - rb_define_global_function("Fiber", rb_f_fiber, -1); + rb_define_singleton_method(rb_cFiber, "schedule", rb_f_fiber, -1); + //rb_define_global_function("Fiber", rb_f_fiber, -1); #ifdef RB_EXPERIMENTAL_FIBER_POOL rb_cFiberPool = rb_define_class("Pool", rb_cFiber); diff --git a/doc/fiber.rdoc b/doc/fiber.rdoc index 8a107f5..584e67f 100644 --- a/doc/fiber.rdoc +++ b/doc/fiber.rdoc @@ -101,7 +101,7 @@ context switching points. https://github.com/ruby/ruby/blob/trunk/doc/fiber.rdoc#L101 We also introduce a new method which simplifies the creation of these non-blocking fibers: - Fiber do + Fiber.schedule do puts Fiber.current.blocking? # false end diff --git a/test/fiber/test_enumerator.rb b/test/fiber/test_enumerator.rb index f88657c..7cd13d7 100644 --- a/test/fiber/test_enumerator.rb +++ b/test/fiber/test_enumerator.rb @@ -24,12 +24,12 @@ class TestFiberEnumerator < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/fiber/test_enumerator.rb#L24 e = i.to_enum(:each_char) - Fiber do + Fiber.schedule do o.write("Hello World") o.close end - Fiber do + Fiber.schedule do begin while c = e.next message << c diff --git a/test/fiber/test_io.rb b/test/fiber/test_io.rb index c23f67e..19f68eb 100644 --- a/test/fiber/test_io.rb +++ b/test/fiber/test_io.rb @@ -22,12 +22,12 @@ class TestFiberIO < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/fiber/test_io.rb#L22 scheduler = Scheduler.new Thread.current.scheduler = scheduler - Fiber do + Fiber.schedule do message = i.read(20) i.close end - Fiber do + Fiber.schedule do o.write("Hello World") o.close end @@ -50,12 +50,12 @@ class TestFiberIO < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/fiber/test_io.rb#L50 scheduler = Scheduler.new Thread.current.scheduler = scheduler - Fiber do + Fiber.schedule do i.read(20) i.close end - Fiber do + Fiber.schedule do o.write("Hello World") o.close end diff --git a/test/fiber/test_mutex.rb b/test/fiber/test_mutex.rb index c4e671f..5179959 100644 --- a/test/fiber/test_mutex.rb +++ b/test/fiber/test_mutex.rb @@ -10,7 +10,7 @@ class TestFiberMutex < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/fiber/test_mutex.rb#L10 scheduler = Scheduler.new Thread.current.scheduler = scheduler - Fiber do + Fiber.schedule do assert_equal Thread.scheduler, scheduler mutex.synchronize do @@ -29,7 +29,7 @@ class TestFiberMutex < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/fiber/test_mutex.rb#L29 scheduler = Scheduler.new Thread.current.scheduler = scheduler - Fiber do + Fiber.schedule do assert_equal Thread.scheduler, scheduler mutex.synchronize do diff --git a/test/fiber/test_scheduler.rb b/test/fiber/test_scheduler.rb index 5055a95..7acf63d 100644 --- a/test/fiber/test_scheduler.rb +++ b/test/fiber/test_scheduler.rb @@ -6,7 +6,7 @@ class TestFiberScheduler < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/fiber/test_scheduler.rb#L6 def test_fiber_without_scheduler # Cannot create fiber without scheduler. assert_raise RuntimeError do - Fiber do + Fiber.schedule do end end end diff --git a/test/fiber/test_sleep.rb b/test/fiber/test_sleep.rb index f1d9f79..a15f2f2 100644 --- a/test/fiber/test_sleep.rb +++ b/test/fiber/test_sleep.rb @@ -13,7 +13,7 @@ class TestFiberSleep < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/fiber/test_sleep.rb#L13 Thread.current.scheduler = scheduler 5.times do |i| - Fiber do + Fiber.schedule do assert_operator sleep(i/100.0), :>=, 0 items << i end @@ -34,7 +34,7 @@ class TestFiberSleep < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/fiber/test_sleep.rb#L34 thread = Thread.new do scheduler = Scheduler.new Thread.current.scheduler = scheduler - Fiber do + Fiber.schedule do seconds = sleep(2) end end -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/