Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Note about merging with concurrent-ruby gem.

  • Loading branch information...
commit e4c9c4059df43519c315c86fff6e10d65f2a3b61 1 parent 3cd3b43
@headius authored
Showing with 2 additions and 52 deletions.
  1. +2 −52
@@ -1,53 +1,3 @@
-atomic: An atomic reference implementation for JRuby, Rubinius, and MRI.
+This library has been moved to
-[![Build Status](](
-This library provides:
-* an Atomic class that guarantees atomic updates to its contained value
-The Atomic class provides accessors for the contained "value" plus two update methods:
-* 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.
-* 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.
-The atomic repository is at
-The simplest way to use "atomic" is to call the "update" or "try_update" methods.
-"try_update" and "update" both call the given block, passing the current value and using the block's result as the new value. If the value is updated by another thread before the block completes, "try update" raises a ConcurrentUpdateError and "update" retries the block. Because "update" may call the block several times when multiple threads are all updating the same value, the block's logic should be kept as simple as possible.
-require 'atomic'
-my_atomic =
-my_atomic.update {|v| v + 1}
- my_atomic.try_update {|v| v + 1}
-rescue Atomic::ConcurrentUpdateError => cue
- # deal with it (retry, propagate, etc)
-It's also possible to use the regular get/set operations on the Atomic, if you want to avoid the exception and respond to contended changes in some other way.
-my_atomic =
-my_atomic.value # => 0
-my_atomic.value = 1
-my_atomic.swap(2) # => 1
-my_atomic.compare_and_swap(2, 3) # => true, updated to 3
-my_atomic.compare_and_swap(2, 3) # => false, current is not 2
-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.
+It will be merged with the concurrent-ruby gem under the same org soon.
Please sign in to comment.
Something went wrong with that request. Please try again.