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:
|
![]() |
MRI 1.9.3, 2.0, 2.1, JRuby (1.9 mode), and Rubinius 2.x are supported. Although native code is used for performance optimizations on some platforms, all functionality is available in pure Ruby. This gem should be fully compatible with any interpreter that is compliant with Ruby 1.9.3 or newer.
We have a roadmap guiding our work toward the v1.0.0 release.
The primary site for documentation is the automatically generated API documentation
We also have a mailing list.
This library contains a variety of concurrency abstractions at high and low levels. One of the high-level abstractions is likely to meet most common needs.
- Actor: Implements the Actor Model, where concurrent actors exchange messages.
- Agent: A single atomic value that represents an identity.
- Async: A mixin module that provides simple asynchronous behavior to any standard class/object or object.
- Future: An asynchronous operation that produces a value.
- Dataflow: Built on Futures, Dataflow allows you to create a task that will be scheduled when all of its data dependencies are available.
- Promise: Similar to Futures, with more features.
- ScheduledTask: Like a Future scheduled for a specific future time.
- TimerTask: A Thread that periodically wakes up to perform work at regular intervals.
- See ThreadPool overview, which also contains a list of other Executors available.
Lower-level abstractions mainly used as building blocks.
Lower-level abstractions mainly used as building blocks.
- AtomicBoolean
- AtomicFixnum
- AtomicReference (no docs currently available, check source)
- I-Structures (IVar)
- M-Structures (MVar)
- thread-local variables
- software transactional memory (TVar)
This gem includes several platform-specific optimizations. To reduce the possibility of compilation errors, we provide pre-compiled gem packages for several platforms as well as a pure-Ruby build. Installing the gem should be no different than installing any other Rubygems-hosted gem. Rubygems will automatically detect your platform and install the appropriate pre-compiled build. You should never see Rubygems attempt to compile the gem on installation. Additionally, to ensure compatability with the largest possible number of Ruby interpreters, the C extensions will never load under any Ruby other than MRI, even when installed.
The following gem builds will be built at every release:
- concurrent-ruby-x.y.z.gem (pure Ruby)
- concurrent-ruby-x.y.z-java.gem (JRuby)
- concurrent-ruby-x.y.z-x86-linux.gem (Linux 32-bit)
- concurrent-ruby-x.y.z-x86_64-linux.gem (Linux 64-bit)
- concurrent-ruby-x.y.z-x86-mingw32.gem (Windows 32-bit)
- concurrent-ruby-x.y.z-x64-mingw32.gem (Windows 64-bit)
- concurrent-ruby-x.y.z-x86-solaris-2.11.gem (Solaris)
gem install concurrent-ruby
or add the following line to Gemfile:
gem 'concurrent-ruby'
and run bundle install
from your shell.
Because we provide pre-compiled gem builds, users should never need to build the gem manually. The build process for this gem is completely automated using open source tools. All of the automation components are available in the ruby-concurrency/rake-compiler-dev-box GitHub repository.
This gem will compile native C code under MRI and native Java code under JRuby. It is also possible to build a pure-Ruby version. All builds have identical functionality. The only difference is performance. Additionally, pure-Ruby classes are always available, even when using the native optimizations. Please see the documentation for more details.
To build and package the gem using MRI or JRuby, install the necessary build dependencies and run:
bundle exec rake compile
bundle exec rake build
To build and package a pure-Ruby gem, on any platform and interpreter (including MRI and JRuby), run:
BUILD_PURE_RUBY='true' bundle exec rake build
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Concurrent Ruby is free software released under the MIT License.
The Concurrent Ruby logo was designed by David Jones. It is Copyright © 2014 Jerry D'Antonio. All Rights Reserved.