https://github.com/ruby-concurrency/ref
A weak reference implementation for Ruby that works across runtimes (MRI, REE, Jruby, Rubinius, and IronRuby)
https://github.com/ruby-concurrency/ref
Keywords from Contributors
background-jobs jobs sidekiq activejob activerecord mvc authorization grape oauth2 feature-flag
Last synced: about 16 hours ago
JSON representation
Repository metadata
A weak reference implementation for Ruby that works across runtimes (MRI, REE, Jruby, Rubinius, and IronRuby)
- Host: GitHub
- URL: https://github.com/ruby-concurrency/ref
- Owner: ruby-concurrency
- License: mit
- Archived: true
- Created: 2010-12-23T15:55:54.000Z (almost 15 years ago)
- Default Branch: master
- Last Pushed: 2020-11-17T21:03:32.000Z (about 5 years ago)
- Last Synced: 2025-12-04T19:40:42.480Z (6 days ago)
- Language: Ruby
- Homepage:
- Size: 103 KB
- Stars: 64
- Watchers: 5
- Forks: 9
- Open Issues: 1
- Releases: 0
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
README.md
Ref
This library provides object references for Ruby as well as some common utilities for working with references. Object references are used to point to other objects and come in three distinct flavors that interact differently with the garbage collector.
Ref::StrongReference- This is a plain old pointer to another object.Ref::WeakReference- This is a pointer to another object, but it is not seen by the garbage collector and the memory used by the object can be reclaimed at any time.Ref::SoftReference- This is similar to a weak reference, but the garbage collector is not as eager to reclaim the referenced object.
All of these classes extend from a common Ref::Reference class and have a common interface.
Weak and soft references are useful when you have instantiated objects that you may want to use again but can recreate if necessary. Since the garbage collector determines when to reclaim the memory used by the objects, you don't need to worry about bloating the Ruby heap.
Example Usage
ref = Ref::WeakReference.new("hello")
ref.object # should be "hello"
ObjectSpace.garbage_collect
ref.object # should be nil (assuming the garbage collector reclaimed the reference)
Goodies
This library also includes tools for some common uses of weak and soft references.
Ref::WeakKeyMap- A map of keys to values where the keys are weak referencesRef::WeakValueMap- A map of keys to values where the values are weak referencesRef::SoftKeyMap- A map of keys to values where the keys are soft referencesRef::SoftValueMap- A map of keys to values where the values are soft referencesRef::ReferenceQueue- A thread safe implementation of a queue that will add references to itself as their objects are garbage collected.
Problems with WeakRef
Ruby does come with the WeakRef class in the standard library. However, there are issues with this class across several different Ruby runtimes. This gem provides a common interface to weak references that works across MRI, Ruby Enterprise Edition, YARV, JRuby and Rubinius.
- Rubinius - Rubinius implements
WeakRefwith a lighter weight version of delegation and works very well. - YARV 1.9 -
WeakRefis unsafe to use because the garbage collector can run in a different system thread than a thread allocating memory. This exposes a bug where aWeakRefmay end up pointing to a completely different object than it originally referenced. - MRI Ruby 2.0+ has a good implementation of
WeakRef.
Owner metadata
- Name: ruby-concurrency
- Login: ruby-concurrency
- Email: concurrent-ruby@googlegroups.com
- Kind: organization
- Description:
- Website:
- Location:
- Twitter:
- Company:
- Icon url: https://avatars.githubusercontent.com/u/5462766?v=4
- Repositories: 5
- Last ynced at: 2024-03-25T19:33:59.022Z
- Profile URL: https://github.com/ruby-concurrency
GitHub Events
Total
Last Year
Committers metadata
Last synced: 4 days ago
Total Commits: 65
Total Committers: 7
Avg Commits per committer: 9.286
Development Distribution Score (DDS): 0.554
Commits in past year: 0
Committers in past year: 0
Avg Commits per committer in past year: 0.0
Development Distribution Score (DDS) in past year: 0.0
| Name | Commits | |
|---|---|---|
| Brian Durand | b****n@e****m | 29 |
| Olle Jonsson | o****n@g****m | 13 |
| Lucas Allan Amorim | l****n@g****m | 11 |
| Jerry D'Antonio | s****r@g****m | 6 |
| Ian Unruh | i****h@g****m | 3 |
| Kim Burgestrand | k****m@b****e | 2 |
| Pedro Andrade | p****e@g****m | 1 |
Committer domains:
Issue and Pull Request metadata
Last synced: 3 months ago
Total issues: 19
Total pull requests: 18
Average time to close issues: 7 months
Average time to close pull requests: about 1 month
Total issue authors: 13
Total pull request authors: 8
Average comments per issue: 2.63
Average comments per pull request: 3.0
Merged pull request: 15
Bot issues: 0
Bot pull requests: 0
Past year issues: 0
Past year pull requests: 0
Past year average time to close issues: N/A
Past year average time to close pull requests: N/A
Past year issue authors: 0
Past year pull request authors: 0
Past year average comments per issue: 0
Past year average comments per pull request: 0
Past year merged pull request: 0
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- jdantonio (7)
- danielwaterworth (1)
- gingerlime (1)
- arkadiyt (1)
- giladbu (1)
- ghost (1)
- CarmelK (1)
- voxik (1)
- strzibny (1)
- lucasallan (1)
- PikachuEXE (1)
- the8472 (1)
- jemc (1)
Top Pull Request Authors
- lucasallan (9)
- jdantonio (3)
- pedroandrade (1)
- schmurfy (1)
- olleolleolle (1)
- Burgestrand (1)
- ianunruh (1)
- kmcclellan (1)
Top Issue Labels
Top Pull Request Labels
Package metadata
- Total packages: 3
-
Total downloads:
- rubygems: 110,024,065 total
- Total docker downloads: 66,407,204
- Total dependent packages: 19 (may contain duplicates)
- Total dependent repositories: 56,640 (may contain duplicates)
- Total versions: 13
- Total maintainers: 4
gem.coop: ref
Library that implements weak, soft, and strong references in Ruby that work across multiple runtimes (MRI,Jruby and Rubinius). Also includes implementation of maps/hashes that use references and a reference queue.
- Homepage: http://github.com/ruby-concurrency/ref
- Documentation: http://www.rubydoc.info/gems/ref/
- Licenses: MIT
- Latest release: 2.0.0 (published over 10 years ago)
- Last Synced: 2025-12-08T12:30:25.369Z (2 days ago)
- Versions: 6
- Dependent Packages: 0
- Dependent Repositories: 0
- Downloads: 55,013,256 Total
- Docker Downloads: 33,203,602
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 0.282%
- Downloads: 0.467%
- Docker downloads count: 0.662%
- Maintainers (4)
rubygems.org: ref
Library that implements weak, soft, and strong references in Ruby that work across multiple runtimes (MRI,Jruby and Rubinius). Also includes implementation of maps/hashes that use references and a reference queue.
- Homepage: http://github.com/ruby-concurrency/ref
- Documentation: http://www.rubydoc.info/gems/ref/
- Licenses: MIT
- Latest release: 2.0.0 (published over 10 years ago)
- Last Synced: 2025-12-06T23:01:55.425Z (4 days ago)
- Versions: 6
- Dependent Packages: 19
- Dependent Repositories: 56,640
- Downloads: 55,010,809 Total
- Docker Downloads: 33,203,602
-
Rankings:
- Dependent repos count: 0.146%
- Downloads: 0.381%
- Docker downloads count: 0.783%
- Dependent packages count: 1.094%
- Average: 3.056%
- Stargazers count: 6.765%
- Forks count: 9.168%
- Maintainers (4)
proxy.golang.org: github.com/ruby-concurrency/ref
- Homepage:
- Documentation: https://pkg.go.dev/github.com/ruby-concurrency/ref#section-documentation
- Licenses: mit
- Latest release: v2.0.0+incompatible (published over 10 years ago)
- Last Synced: 2025-12-06T23:01:57.394Z (4 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Stargazers count: 5.252%
- Forks count: 6.637%
- Average: 8.067%
- Dependent packages count: 9.576%
- Dependent repos count: 10.802%
Dependencies
- coveralls ~> 0.8.21 development
- inch ~> 0.4.6 development
- rake ~> 10.3.2 development
- rake-compiler = 0.9.5 development
- redcarpet ~> 3.1.2 development
- rspec ~> 3.6 development
- test-unit ~> 3.0.9 development
- yard ~> 0.8.7.4 development
Score: 25.109063706690662