@@ -47,9 +47,6 @@ class IVar < Synchronization::Object
4747 include Concern ::Obligation
4848 include Concern ::Observable
4949
50- # @!visibility private
51- NO_VALUE = Object . new # :nodoc:
52-
5350 # Create a new `IVar` in the `:pending` state with the (optional) initial value.
5451 #
5552 # @param [Object] value the initial value
@@ -60,8 +57,8 @@ class IVar < Synchronization::Object
6057 # returning the data
6158 # @option opts [String] :copy_on_deref (nil) call the given `Proc` passing
6259 # the internal value and returning the value returned from the proc
63- def initialize ( value = NO_VALUE , opts = { } , &block )
64- if value != NO_VALUE && block_given?
60+ def initialize ( value = NULL , opts = { } , &block )
61+ if value != NULL && block_given?
6562 raise ArgumentError . new ( 'provide only a value or a block' )
6663 end
6764 super ( &nil )
@@ -102,16 +99,16 @@ def add_observer(observer = nil, func = :update, &block)
10299
103100 # @!macro [attach] ivar_set_method
104101 # Set the `IVar` to a value and wake or notify all threads waiting on it.
105- #
102+ #
106103 # @!macro [attach] ivar_set_parameters_and_exceptions
107104 # @param [Object] value the value to store in the `IVar`
108105 # @yield A block operation to use for setting the value
109106 # @raise [ArgumentError] if both a value and a block are given
110107 # @raise [Concurrent::MultipleAssignmentError] if the `IVar` has already
111108 # been set or otherwise completed
112- #
109+ #
113110 # @return [IVar] self
114- def set ( value = NO_VALUE )
111+ def set ( value = NULL )
115112 check_for_block_or_value! ( block_given? , value )
116113 raise MultipleAssignmentError unless compare_and_set_state ( :processing , :pending )
117114
@@ -128,7 +125,7 @@ def set(value = NO_VALUE)
128125
129126 # @!macro [attach] ivar_fail_method
130127 # Set the `IVar` to failed due to some error and wake or notify all threads waiting on it.
131- #
128+ #
132129 # @param [Object] reason for the failure
133130 # @raise [Concurrent::MultipleAssignmentError] if the `IVar` has already
134131 # been set or otherwise completed
@@ -143,7 +140,7 @@ def fail(reason = StandardError.new)
143140 # @!macro ivar_set_parameters_and_exceptions
144141 #
145142 # @return [Boolean] true if the value was set else false
146- def try_set ( value = NO_VALUE , &block )
143+ def try_set ( value = NULL , &block )
147144 set ( value , &block )
148145 true
149146 rescue MultipleAssignmentError
@@ -159,7 +156,7 @@ def ns_initialize(value, opts)
159156 self . observers = Collection ::CopyOnWriteObserverSet . new
160157 set_deref_options ( opts )
161158
162- if value == NO_VALUE
159+ if value == NULL
163160 @state = :pending
164161 else
165162 ns_complete_without_notification ( true , value , nil )
@@ -202,7 +199,7 @@ def ns_complete_without_notification(success, value, reason)
202199
203200 # @!visibility private
204201 def check_for_block_or_value! ( block_given , value ) # :nodoc:
205- if ( block_given && value != NO_VALUE ) || ( ! block_given && value == NO_VALUE )
202+ if ( block_given && value != NULL ) || ( ! block_given && value == NULL )
206203 raise ArgumentError . new ( 'must set with either a value or a block' )
207204 end
208205 end
0 commit comments