From: Charles Oliver Nutter Date: 2007-08-28T02:25:07+09:00 Subject: Re: Fibers in Ruby 1.9? SASADA Koichi wrote: > I think Fiber class is not needed for most of people. Because 1.9 > support Enumerator as outer iterater (I'm not sure about this > nameing) such as Java's Iterator or Python's Generator or Ruby's > 'generator' library and so on. ... > Main purpose of Fiber is to realise outer iterator. In fact, > Enumerator#next using Fiber. So I think ruby/test_enumerator.rb is > more important test than implement Fiber's methods. Yes, we don't have the enumerator work started yet in JRuby, but I don't expect it to be too difficult. Primarily I'm interested in implementing the coroutine features of Fiber, and that much is mostly complete now in my implementation. > Easy instruction: > ================= > > Fiber#resume > Resume Fiber's context. > > Fiber.yield(...) > return values to resuming context. yield and resume aren't hard to do, so I have those working in JRuby now. > Fiber.current > return current fiber. current only works from within an explicitly-constructed Fiber; i.e. you can't get a fiber out of an arbitrary thread. It wouldn't be hard to fix, though. > Fiber#alive? > return if this fiber is alive or not. Works ok. > Fiber#transfer > tranfer fiber context. This method break resume/yield > (parent/child) relation, so we shouldn't use it (this method is > similar to callcc). As we discussed on line, since this is a continuation-style feature, JRuby would not be able to support if. If you moved this to unsafe/fiber as you mentioned on line it would provide a good division. JRuby could support the "safe" fiber behavior. Thanks for the help...I'll let you know if I have more questions. - Charlie