Class: Concurrent::AtomicBoolean
- Inherits:
-
AtomicBooleanImplementation
- Object
- Concurrent::AtomicBoolean
- Defined in:
- lib/concurrent/atomic/atomic_boolean.rb
Overview
A boolean value that can be updated atomically. Reads and writes to an atomic boolean and thread-safe and guaranteed to succeed. Reads and writes may block briefly but no explicit locking is required.
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) false?
Is the current value
false
. -
- (undocumented) initialize(initial = false)
constructor
Creates a new
AtomicBoolean
with the given initial value. -
- (Boolean) make_false
Explicitly sets the value to false.
-
- (Boolean) make_true
Explicitly sets the value to true.
-
- (String) to_s
(also: #inspect)
Short string representation.
-
- (Boolean) true?
Is the current value
true
. -
- (Boolean) value
Retrieves the current
Boolean
value. -
- (Boolean) value=(value)
Explicitly sets the value.
Constructor Details
- (undocumented) initialize(initial = false)
Creates a new AtomicBoolean
with the given initial value.
114 115 116 117 118 119 120 121 |
# File 'lib/concurrent/atomic/atomic_boolean.rb', line 114 class AtomicBoolean < AtomicBooleanImplementation # @return [String] Short string representation. def to_s format '<#%s:0x%x value:%s>', self.class, object_id << 1, value end alias_method :inspect, :to_s end |
Instance Method Details
- (Boolean) false?
Is the current value false
114 115 116 117 118 119 120 121 |
# File 'lib/concurrent/atomic/atomic_boolean.rb', line 114 class AtomicBoolean < AtomicBooleanImplementation # @return [String] Short string representation. def to_s format '<#%s:0x%x value:%s>', self.class, object_id << 1, value end alias_method :inspect, :to_s end |
- (Boolean) make_false
Explicitly sets the value to false.
114 115 116 117 118 119 120 121 |
# File 'lib/concurrent/atomic/atomic_boolean.rb', line 114 class AtomicBoolean < AtomicBooleanImplementation # @return [String] Short string representation. def to_s format '<#%s:0x%x value:%s>', self.class, object_id << 1, value end alias_method :inspect, :to_s end |
- (Boolean) make_true
Explicitly sets the value to true.
114 115 116 117 118 119 120 121 |
# File 'lib/concurrent/atomic/atomic_boolean.rb', line 114 class AtomicBoolean < AtomicBooleanImplementation # @return [String] Short string representation. def to_s format '<#%s:0x%x value:%s>', self.class, object_id << 1, value end alias_method :inspect, :to_s end |
- (String) to_s Also known as: inspect
Returns Short string representation.
116 117 118 |
# File 'lib/concurrent/atomic/atomic_boolean.rb', line 116 def to_s format '<#%s:0x%x value:%s>', self.class, object_id << 1, value end |
- (Boolean) true?
Is the current value true
114 115 116 117 118 119 120 121 |
# File 'lib/concurrent/atomic/atomic_boolean.rb', line 114 class AtomicBoolean < AtomicBooleanImplementation # @return [String] Short string representation. def to_s format '<#%s:0x%x value:%s>', self.class, object_id << 1, value end alias_method :inspect, :to_s end |
- (Boolean) value
Retrieves the current Boolean
value.
114 115 116 117 118 119 120 121 |
# File 'lib/concurrent/atomic/atomic_boolean.rb', line 114 class AtomicBoolean < AtomicBooleanImplementation # @return [String] Short string representation. def to_s format '<#%s:0x%x value:%s>', self.class, object_id << 1, value end alias_method :inspect, :to_s end |
- (Boolean) value=(value)
Explicitly sets the value.
114 115 116 117 118 119 120 121 |
# File 'lib/concurrent/atomic/atomic_boolean.rb', line 114 class AtomicBoolean < AtomicBooleanImplementation # @return [String] Short string representation. def to_s format '<#%s:0x%x value:%s>', self.class, object_id << 1, value end alias_method :inspect, :to_s end |