A collection of thread-safe versions of common core Ruby classes.
Add this line to your application's Gemfile:
gem 'thread_safe'
And then execute:
$ bundle
Or install it yourself as:
$ gem install thread_safe
require 'thread_safe' sa = ThreadSafe::Array.new # supports standard Array.new forms sh = ThreadSafe::Hash.new # supports standard Hash.new forms
ThreadSafe::Cache
also exists, as a hash-like object, and should have
much better performance characteristics under concurrency than
ThreadSafe::Hash
. However, ThreadSafe::Cache
is not strictly semantically
equivalent to ruby Hash -- for instance, it does not neccesarily ordered by
insertion time as Hash is. For most uses it should do fine though, and we
recommend you consider ThreadSafe::Cache
instead of ThreadSafe::Hash
for your
concurrency-safe hash needs.
git clone git@github.com:you/thread_safe.git
)git checkout -b my-new-feature
)rake jar
) NOTE: Requires JRubybundle install
)git commit -am 'Added some feature'
)git push origin my-new-feature
)