talira

Concurrent Ruby

Thread-safe futures, promises, thread pools, agents and atomics for Ruby

open sourceMITfree

Concurrent Ruby is a toolbox of concurrency abstractions for Ruby, inspired by Erlang, Clojure, Scala, Java and other languages, with no external gem dependencies. It offers promises and futures, scheduled and timer tasks, Java-style thread pools and executors, Clojure-style agents, thread-safe Array, Hash and Map, atomic references and other thread-safe variables, and synchronization primitives such as semaphores and latches. Every abstraction is thread safe on MRI/CRuby, JRuby and TruffleRuby. Actors and other experimental features ship in the separate concurrent-ruby-edge gem.

Problems it solves

  • run background work in a thread pool in Ruby
  • share a hash safely between threads in a Ruby app
  • chain asynchronous tasks with futures and promises in Ruby

Features

  • promises and futures, non-blocking and lock-free
  • Java-style thread pools and executors
  • Clojure-style agents and atomic references
  • thread-safe Array, Hash and Map
  • semaphores, latches and other synchronization primitives

Limitations

  • Features in concurrent-ruby-edge stay at version 0.y.z and may change incompatibly at any time1

Alternatives

The same job

These do what Concurrent Ruby does.

  1. parallel (Ruby) Run Ruby code in parallel processes, threads or Ractors

Compare Concurrent Ruby with the top 3