百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
T

thread_safe

> 编程语言
开源

适用于 Ruby 的线程安全集合 (与 concurrent-ruby 合并)

192 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

适用于 Ruby 的线程安全集合 (与 concurrent-ruby 合并)

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

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

ruby
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:

ruby
require 'thread_safe'

cache = ThreadSafe::Cache.new

Contributing

  1. Fork it
  2. Clone it (git clone [email protected]: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

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Java

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言