natalie icon indicating copy to clipboard operation
natalie copied to clipboard

Unblocked Fibers

Open herwinw opened this issue 1 year ago • 0 comments

This is a feature of Ruby 3.0 where a Fiber can mark itself as being blocked, notify a scheduler of this information, and let the scheduler change the execution to a different fiber. Given that we currently have Fibers but no Threads, this is probably the easiest way into getting some form of concurrency into Natalie.

I found some example scripts on https://blog.monotone.dev/ruby/2020/12/25/ruby-3-fiber.html and I want those to work with Natalie.

This does require the following steps:

  • [x] Add blocking status to Fiber (#1166)
  • [x] Add a possibility to get and set the Fiber scheduler (#1183)
  • [x] Get the kernel_sleep example to work. This requires at least updates to the sleep method to make the callback (#1287)
  • [ ] Get the io_wait example to work
  • [ ] Get the block/unblock example to work. This probably requires some more primitives in the code, like Mutex and Queue

herwinw avatar Aug 31 '23 06:08 herwinw