Ruby 3.0 and the new FiberScheduler interface

A few days ago on Christmas day 2020, Matz released Ruby 3.0. Like every year, a host of interesting new features was included with the new version. Most articles I have read so far focus more on the new ways to introduce type hints and the Ractor system but for me the most interesting addition was the introduction of the Fiber::SchedulerInterface class. It allows for (but does not yet implement) more advanced event loop based schedulers for non-blocking I/O in Ruby. Several advanced techniques already exist for this in Ruby, from event loop frameworks like EventMachine and Async to releasing the GVL in C extensions, but this new interface is more exciting to me because it makes it much easier to accidentally do the right thing.

In this post I’ll go over the way the scheduler interface works in “normal” Ruby, and how to access it from within MRI C extensions. We’ll also have a look at the drawbacks of the current interface, because nothing is perfect.

http://www.wjwh.eu/posts/2020-12-28-ruby-fiber-scheduler-c-extension.html

This thread was posted by one of our members via one of our automated news source trackers.

Corresponding tweet for this thread:

https://twitter.com/dev_talk/status/1344194351824580608

Share link for this tweet.


Related portal: