Concurrent Ruby provides thread-safe abstractions for Ruby, including promises, agents, thread pools, and synchronized collections, on MRI, JRuby, and TruffleRuby.
Overview
Concurrent Ruby is a gem that collects modern concurrency primitives for Ruby programs. Its APIs borrow patterns from Erlang, Clojure, Scala, Java, and related ecosystems while staying idiomatic to Ruby.
The core package includes promises and futures, scheduled and timer tasks, asynchronous helpers, and Java-style executors with thread pools. Thread-safe collections and variables cover arrays, hashes, maps, agents, atoms, transactional TVars, and more.
Synchronization utilities include latches, barriers, read-write locks, semaphores, and events. The project documents thread-safety guarantees per abstraction and targets consistent behavior across MRI, JRuby, and TruffleRuby.
An optional concurrent-ruby-edge companion gem ships experimental actor, channel, and cancellation APIs that may move into core when stable. Optional C extensions in concurrent-ruby-ext can improve performance on MRI.
Key features
- Unified promises and futures framework
- Thread pools and executor abstractions
- Agents, atoms, and STM TVars
- Thread-safe collections and structs
- Count-down latches and cyclic barriers
- Read-write and reentrant locks
- Edge gem actors and channels
- Optional MRI C extensions
Use cases
- Coordinating work across Ruby threads
- Background job scheduling in Ruby
- Shared mutable state with agents
- Parallel pipelines with promises