Class: Concurrent::AtomicReference
- Inherits:
-
JavaAtomicReference
- Object
- JavaAtomicReference
- Concurrent::AtomicReference
- Defined in:
- lib/concurrent/atomic/atomic_reference.rb,
lib/concurrent/atomic/atomic_reference.rb
Overview
An object reference that may be updated atomically. All read and write operations have java volatile semantic.
Testing with ruby 2.1.2 Testing with Concurrent::MutexAtomicBoolean... 2.790000 0.000000 2.790000 ( 2.791454) Testing with Concurrent::CAtomicBoolean... 0.740000 0.000000 0.740000 ( 0.740206)
Testing with jruby 1.9.3 Testing with Concurrent::MutexAtomicBoolean... 5.240000 2.520000 7.760000 ( 3.683000) Testing with Concurrent::JavaAtomicBoolean... 3.340000 0.010000 3.350000 ( 0.855000)
Instance Method Summary (collapse)
-
- (Boolean) compare_and_set
Atomically sets the value to the given updated value if the current value == the expected value.
-
- (Object) get
Gets the current value.
-
- (Object) get_and_set
Atomically sets to the given value and returns the old value.
- - (undocumented) initialize constructor
-
- (Object) set
Sets to the given value.
-
- (String) to_s
(also: #inspect)
Short string representation.
Constructor Details
- (undocumented) initialize
22 23 |
# File 'lib/concurrent/atomic/atomic_reference.rb', line 22 class Concurrent::AtomicReference < Concurrent::JavaAtomicReference end |
Instance Method Details
- (Boolean) compare_and_set
Atomically sets the value to the given updated value if the current value == the expected value.
that the actual value was not equal to the expected value.
22 23 |
# File 'lib/concurrent/atomic/atomic_reference.rb', line 22 class Concurrent::AtomicReference < Concurrent::JavaAtomicReference end |
- (Object) get
Gets the current value.
22 23 |
# File 'lib/concurrent/atomic/atomic_reference.rb', line 22 class Concurrent::AtomicReference < Concurrent::JavaAtomicReference end |
- (Object) get_and_set
Atomically sets to the given value and returns the old value.
22 23 |
# File 'lib/concurrent/atomic/atomic_reference.rb', line 22 class Concurrent::AtomicReference < Concurrent::JavaAtomicReference end |
- (Object) set
Sets to the given value.
22 23 |
# File 'lib/concurrent/atomic/atomic_reference.rb', line 22 class Concurrent::AtomicReference < Concurrent::JavaAtomicReference end |
- (String) to_s Also known as: inspect
Returns Short string representation.
46 47 48 |
# File 'lib/concurrent/atomic/atomic_reference.rb', line 46 def to_s format '<#%s:0x%x value:%s>', self.class, object_id << 1, get end |