Skip to content

Instantly share code, notes, and snippets.

@epitron
Created February 25, 2026 03:46
Show Gist options
  • Select an option

  • Save epitron/7d8d2a6cd7ee7903a6377e3637249f16 to your computer and use it in GitHub Desktop.

Select an option

Save epitron/7d8d2a6cd7ee7903a6377e3637249f16 to your computer and use it in GitHub Desktop.
Ractor::Port Fan-Out: One Producer, Many Workers
tasks = Ractor::Port.new
results = Ractor::Port.new
workers = 4.times.map do
Ractor.new(tasks, results) do |t, r|
loop do
job = t.receive
r.send(job * job)
end
end
end
10.times { |i| tasks.send(i) }
10.times { puts results.receive }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment