Hacker News Re-Imagined

Ruby 3 adds Scheduler Interface for Fibers

  • 85 points
  • 12 days ago

  • @ksec
  • Created a post

Ruby 3 adds Scheduler Interface for Fibers


@brunosutic 12 days

Replying to @ksec 🎙

I feel like the linked article is based heavily on my own article on the same subject: https://brunosutic.com/blog/ruby-fiber-scheduler

Too bad the article doesn't contain the source reference, but oh well. I hope it gets the word out about this new cool stuff in Ruby.

Reply


@ptx 12 days

Replying to @ksec 🎙

Can this be used for UI callbacks as well, like async/await in C# and coroutines in Kotlin?

In other words, with an appropriate fiber scheduler, could I start a function on the UI thread, suspend it while performing some background operation and then resume the same function again on the UI thread?

Reply


@dalyons 12 days

Replying to @ksec 🎙

i think this announcement https://brunosutic.com/blog/async-ruby & the associated async libraries (https://github.com/socketry/async) do a much better job of showing off the potential for the ruby 3.1+ fiber scheduler. Async gem is powered by a fiber scheduler under the hood, and what you get is un-colored async-ready ruby code.

That is to say, you can write a normal rack app with falcon-async as the webserver and get node/event-loop scale co-operative concurrency without changing your code. Its pretty exciting!

Unfortunately rails makes heavy use of thread locals which arent compatible with fiber concurrency, so its going to take awhile until its async-ready, but I believe progress is being made (Async ActiveRecord was merged recently).

Reply


About Us

site design / logo © 2022 Box Piper