Ractor - Ruby’s Actor-like concurrent abstraction ↑

Ractor is designed to provide a parallel execution feature of Ruby without thread-safety concerns.

Summary ↑

Multiple Ractors in an interpreter process ↑

You can make multiple Ractors and they run in parallel.

Limited sharing between multiple ractors ↑

Ractors don’t share everything, unlike threads.

Two-types communication between Ractors ↑

Ractors communicate with each other and synchronize the execution by message exchanging between Ractors. There are two message exchange protocols: push type (message passing) and pull type.

Copy & Move semantics to send messages ↑

To send unshareable objects as messages, objects are copied or moved.

Thread-safety ↑

Ractor helps to write a thread-safe concurrent program, but we can make thread-unsafe programs with Ractors.

Without Ractor, we need to trace all of state-mutations to debug thread-safety issues. With Ractor, you can concentrate to suspicious code which are shared with Ractors.

Creation and termination ↑

Ractor.new ↑

# Ractor.new with a block creates new Ractor
r = Ractor.new do
  # This block will be run in parallel with other ractors
end

# You can name a Ractor with `name:` argument.
r = Ractor.new name: 'test-name' do
end

# and Ractor#name returns its name.
r.name #=> 'test-name'

Given block isolation ↑

The Ractor execute given expr in a given block. Given block will be isolated from outer scope by Proc#isolate. To prevent sharing unshareable objects between ractors, block outer-variables, self and other information are isolated.

Given block will be isolated by Proc#isolate method (not exposed yet for Ruby users). Proc#isolate is called at