11.23
Repository is archived
No commit activity in last 3 years
No release in over 3 years
A collection of data structures and utilities to make thread-safe programming in Ruby easier
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

= 1.1.16
< 12.0
~> 3.2
 Project Readme

Threadsafe (Inactive, code moved to concurrent-ruby gem and repo.)

Gem Version Build Status Coverage Status Code Climate Dependency Status License Gitter chat

A collection of thread-safe versions of common core Ruby classes.

This code base is now part of the concurrent-ruby gem at https://github.com/ruby-concurrency/concurrent-ruby. The code in this repository is no longer maintained.

Installation

Add this line to your application's Gemfile:

gem 'thread_safe'

And then execute:

$ bundle

Or install it yourself as:

$ gem install thread_safe

Usage

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 esp. under high concurrency than ThreadSafe::Hash. However, ThreadSafe::Cache is not strictly semantically equivalent to a ruby Hash -- for instance, it does not necessarily retain ordering by insertion time as Hash does. 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. It understands some options when created (depending on your ruby platform) that control some of the internals - when unsure just leave them out:

require 'thread_safe'

cache = ThreadSafe::Cache.new

Contributing

  1. Fork it
  2. Clone it (git clone git@github.com:you/thread_safe.git)
  3. Create your feature branch (git checkout -b my-new-feature)
  4. Build the jar (rake jar) NOTE: Requires JRuby
  5. Install dependencies (bundle install)
  6. Commit your changes (git commit -am 'Added some feature')
  7. Push to the branch (git push origin my-new-feature)
  8. Create new Pull Request