ruby-concurrency /concurrent-ruby
Modern concurrency tools including agents, futures, promises, thread pools, supervisors, and more. Inspired by Erlang, Clojure, Scala, Go, Java, JavaScript, and classic concurrency patterns.
★ 5,836⑂ 424👁 113⑃ 681● 429▤ 62
+1
日增长
5,836
stars
424
forks
113
watchers
681
prs
429
issues
62
releases
README
Concurrent Ruby

Modern concurrency tools for Ruby. Inspired by
Erlang,
Clojure,
Scala,
Haskell,
F,
C,
Java,
and classic concurrency patterns.
The design goals of this gem are:
Be an 'unopinionated' toolbox that provides useful utilities without debating which is better
or why
Remain free of external gem dependencies
Stay true to the spirit of the languages providing inspiration
But implement in a way that makes sense for Ruby
Keep the semantics as idiomatic Ruby as possible
Support features that make sense in Ruby
Exclude features that don't make sense in Ruby
Be small, lean, and loosely coupled
Thread-safety
Backward compatibility
Contributing
This gem depends on
contributions and we
appreciate your help. Would you like to contribute? Great! Have a look at
issues with looking-for-contributor label. And if you pick something up let us know on the issue.
You can also get started by triaging issues which may include reproducing bug reports or asking for vital information, such as version numbers or reproduction instructions. If you would like to start triaging issues, one easy way to get started is to subscribe to concurrent-ruby on CodeTriage.
Thread Safety
Concurrent Ruby makes one of the strongest thread safety guarantees of any Ruby concurrency
library, providing consistent behavior and guarantees on all three main Ruby interpreters
(MRI/CRuby, JRuby, TruffleRuby).
Every abstraction in this library is thread safe. Specific thread safety guarantees are documented
with each abstraction.
It is critical to remember, however, that Ruby is a language of mutable references. No
concurrency library for Ruby can ever prevent the user from making thread safety mistakes (such as
sharing a mutable object between threads and modifying it on both threads) or from creating
deadlocks through incorrect use of locks. All the library can do is provide safe abstractions which
encourage safe practices. Concurrent Ruby provides more safe concurrency abstractions than any
other Ruby library, many of which support the mantra of
"Do not communicate by sharing memory; instead, share memory by communicating".
Concurrent Ruby is also the only Ruby library which provides a full suite of thread safe and
immutable variable types and data structures.
We've also initiated discussion to document the memory model of Ruby which
would provide consistent behaviour and guarantees on all three main Ruby interpreters
(MRI/CRuby, JRuby, TruffleRuby).
Features & Documentation
The primary site for documentation is the automatically generated
API documentation which is up to
date with latest release. This readme matches the master so may contain new stuff not yet
released.
We also have a IRC (gitter).
Versioning
concurrent-ruby uses Semantic Versioning
concurrent-ruby-ext has always same version as concurrent-ruTop issues
#585Rails5, auto-loading, future, circular dependency49 comments · 2016-10-13#634Thread pool exception handling16 comments · 2017-03-02#493No good tools for long streams of tasks15 comments · 2016-01-09#595Remove all global state not just configuration11 comments · 2016-11-05#1095Implement FIFO and LRU caches through a Map memory limit10 comments · 2025-12-08#929Concurrent::Hash and Concurrent::Array are not fully threadsafe on CRuby9 comments · 2021-12-14#1008DaemonThreadFactory creating new Java thread factory each time it creates a new thread8 comments · 2023-08-24#970`Concurrent::Hash` default initialization is not fully thread-safe8 comments · 2022-11-17
Discussions
#1074Wiki page on using ThreadPool in a Rails app0 comments · 2024-12-17#1050Edge dependencies1 comments · 2024-06-06#1011Echo Server does not work1 comments · 2023-09-30#1010Writing cache for long running computation2 comments · 2023-09-18#995can't compile gems for migration2 comments · 2023-05-23#910How do I sync up all of my green threads and wait until they finish executing before allowing my program to continue?1 comments · 2021-05-26
Latest release
v1.3.8 v1.3.8 2026-07-19What's Changed Programatically set the backtrace_location on exception by @Edouard-chin in https://github.com/ruby-concurrency/concurrent-ruby/pull/1107 Allow to use Concurrent::Mapcompute_if_absent in a Ractor by @Edouard-chin in https://github.com/ruby-concurrency/concurrent-ruby/pull/1109 New Contributors @Edouard-chin made their first contribution in https://github.com/ruby-concurrency/concurrent-ruby/pull/1107 Full Changelog: https://github.com/ruby-concurrency/concurrent-ruby/compare/v1.3.7...v1.3.8