You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 15, 2022. It is now read-only.
An atomic reference implementation for JRuby, Rubinius, and MRI.
6
+
7
+
# Deprecated!
8
+
9
+
*This gem has been deprecated in lieu of [Concurrent Ruby](http://www.concurrent-ruby.com).
10
+
This gem will be retained in GitHUb and Rubygems.org indefinitely but no new development
11
+
will occur, including updates to support new versions of Ruby, JRuby, and Java. All users
12
+
of this gem are encouraged to update their projects to use `concurrent-ruby` instead.*
13
+
14
+
All code from this gem has been merged into `concurrent-ruby` and its companion gems.
15
+
All abstrations in this library are available in `concurrent-ruby` but have been moved
16
+
under the `Concurrent` module to avoid namespace collisions.
17
+
18
+
```ruby
19
+
# old way
20
+
require'atomic'
21
+
my_atomic =Atomic.new(0)
22
+
23
+
# new way
24
+
require'concurrent'
25
+
my_atomic =Concurrent::Atomic.new(0)
26
+
```
27
+
28
+
# Old Documentation
29
+
30
+
*For historic purposes only...*
31
+
32
+
## Summary
8
33
9
34
This library provides:
10
35
@@ -15,10 +40,9 @@ The Atomic class provides accessors for the contained "value" plus two update me
15
40
* update will run the provided block, passing the current value and replacing it with the block result if the value has not been changed in the meantime. It may run the block repeatedly if there are other concurrent updates in progress.
16
41
* try_update will run the provided block, passing the current value and replacing it with the block result. If the value changes before the update can happen, it will throw an Atomic::ConcurrentUpdateError.
17
42
18
-
The atomic repository is at http://github.com/headius/ruby-atomic.
43
+
The atomic repository is at http://github.com/ruby-concurrency/ruby-atomic.
19
44
20
-
Usage
21
-
=====
45
+
## Usage
22
46
23
47
The simplest way to use "atomic" is to call the "update" or "try_update" methods.
my_atomic.compare_and_swap(2, 3) # => false, current is not 2
48
72
```
49
73
50
-
Building
51
-
========
74
+
## Building
52
75
53
76
As of 1.1.0, JDK8 is required to build the atomic gem, since it attempts to use the new atomic Unsafe.getAndSetObject method only in JDK8. The resulting code should still work fine as far back as Java 5.
0 commit comments