What have you found for these years?


ruby coroutine with fiber or enumerator

Fiber uses "yield" and "resume", while
Enumerator uses "yield" and "next".
You can "rewind" on Enumerator, but not on Fiber.

I think both Fiber and Enumerator should respond to call,
the former aliases resume to call, and the latter aliases next to call.

As you can see, they can be somehow identical in terms of interface.
full code: godfat/sandbox/ruby/coroutine.rb
FactFiber = lambda{
          Fiber.yield(r  = x  = 1)
    loop{ Fiber.yield(r *= x += 1) }

FactEnume = lambda{
  Enumerator.new{ |fiber|
          fiber.yield(r  = x  = 1)
    loop{ fiber.yield(r *= x += 1) }
* [Ruby 1.9-Feature#4326][Open] Fiber should respond to call() and []
* 1849. 01-29 是 parent 還是 child?

0 retries:

Post a Comment

Note: Only a member of this blog may post a comment.

All texts are licensed under CC Attribution 3.0