Project

General

Profile

Bug #17331

Updated by nevans (Nicholas Evans) about 1 year ago

It This seems like a feature that would be just as useful to use `raise` on for transferring fibers just as we can with it is for yielding fibers. 

 I've added I'm using a `transfer` kwarg, so it this is not automatic; the caller must know how to handle the fiber.    If you call a yielding fiber with `transfer: true` or a transferring fiber without `transfer: true`, a `FiberError` will be raised. Resuming fibers still raise a `FiberError`. 

 ```ruby 
 yielding_fiber.raise "message" 
 transferring_fiber.raise "message", transfer: true 
 ``` 

 Implementation: https://github.com/ruby/ruby/pull/3783 


 I also implemented a second version that implicitly and automatically selects `rb_fiber_transfer_kw` for transferring fibers and `rb_fiber_resume_kw` for yielding fibers. The implicit version also raises `FiberError` on resuming fibers. 


 ```ruby 
 yielding_fiber.raise "message" 
 transferring_fiber.raise "message", transfer: true 
 ``` 

 Alternate implicit implementation: https://github.com/ruby/ruby/pull/3795

Back