Async Ruby

Explore options for asynchrony in Ruby, including threads, mutexes, queues, Reactors, Futures, Promises, Fibers, Guilds and much more.

It is—by far—easiest to reason about our code if we can think about one linear story at a time. For example:

“Once upon a time, the little chat server read a string of characters from a socket. Then one by one, it send copies of that string of characters to every other client connected to it. The end.”

For some programs, we get to tell these kinds of straight-line stories, and let the operating system worry about multi-tasking. But all too often, we have to directly contend with the hardships of concurrency and asynchrony. At the least, have to take multi-threading considerations into account when implementing a library. At the other extreme, for some tasks we may have to do our own thread coordination, or find a way to cooperatively interleave our code’s “stories” to keep them from blocking each other.

In this course, we’ll look at the advantages and gotchas of a number of different Ruby asynchrony mechanisms. We’ll talk about threads, mutexes, condition variables, and queues. We’ll explore the concepts of Reactors, Futures, and Promises. And we’ll take a look at alternatives to traditional threads, like Fibers and Guilds.

This course is a Graceful.Dev Garden Path, which means it is a guided pathway through a collection of (mostly) self-contained topics. Its status is: growing, meaning that there is a significant amount of material here already, and more is expected in the future.

Prerequisites: you may want to complete some or all of the Ruby Fluency Tour prior to this course. Consider taking Systems Ruby, especially for the coverage of OS processes.

Not Enrolled

Course Includes

  • 3 Modules
  • 25 Topics