Skip to content

Commit 3c040d9

Browse files
committed
Move array, hash, and map to main space; suerseed NO_VALUE with NULL
1 parent d6e8b03 commit 3c040d9

File tree

12 files changed

+23
-26
lines changed

12 files changed

+23
-26
lines changed

lib/concurrent.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
require 'concurrent/atomic/atomic_reference'
1212
require 'concurrent/atom'
13-
require 'concurrent/collection/array'
14-
require 'concurrent/collection/hash'
15-
require 'concurrent/collection/map'
16-
require 'concurrent/collection/tuple'
13+
require 'concurrent/array'
14+
require 'concurrent/hash'
15+
require 'concurrent/map'
16+
require 'concurrent/tuple'
1717
require 'concurrent/async'
1818
require 'concurrent/dataflow'
1919
require 'concurrent/delay'
File renamed without changes.

lib/concurrent/future.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Future < IVar
2727
# @raise [ArgumentError] if no block is given
2828
def initialize(opts = {}, &block)
2929
raise ArgumentError.new('no block given') unless block_given?
30-
super(IVar::NO_VALUE, opts.merge(__task_from_block__: block), &nil)
30+
super(NULL, opts.merge(__task_from_block__: block), &nil)
3131
end
3232

3333
# Execute an `:unscheduled` `Future`. Immediately sets the state to `:pending` and
@@ -74,7 +74,7 @@ def self.execute(opts = {}, &block)
7474
end
7575

7676
# @!macro ivar_set_method
77-
def set(value = IVar::NO_VALUE, &block)
77+
def set(value = NULL, &block)
7878
check_for_block_or_value!(block_given?, value)
7979
synchronize do
8080
if @state != :unscheduled
File renamed without changes.

lib/concurrent/ivar.rb

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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
File renamed without changes.

lib/concurrent/promise.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ class Promise < IVar
205205
# @see http://promises-aplus.github.io/promises-spec/
206206
def initialize(opts = {}, &block)
207207
opts.delete_if { |k, v| v.nil? }
208-
super(IVar::NO_VALUE, opts.merge(__promise_body_from_block__: block), &nil)
208+
super(NULL, opts.merge(__promise_body_from_block__: block), &nil)
209209
end
210210

211211
# Create a new `Promise` and fulfill it immediately.
@@ -254,7 +254,7 @@ def execute
254254
# @!macro ivar_set_method
255255
#
256256
# @raise [Concurrent::PromiseExecutionError] if not the root promise
257-
def set(value = IVar::NO_VALUE, &block)
257+
def set(value = NULL, &block)
258258
raise PromiseExecutionError.new('supported only on root promise') unless root?
259259
check_for_block_or_value!(block_given?, value)
260260
synchronize do

lib/concurrent/scheduled_task.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def initialize(delay, opts = {}, &task)
163163
raise ArgumentError.new('no block given') unless block_given?
164164
raise ArgumentError.new('seconds must be greater than zero') if delay.to_f < 0.0
165165

166-
super(IVar::NO_VALUE, opts, &nil)
166+
super(NULL, opts, &nil)
167167

168168
synchronize do
169169
ns_set_state(:unscheduled)

lib/concurrent/thread_safe/util.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module Util
1313
end
1414
end
1515

16-
require 'concurrent/collection/tuple'
16+
require 'concurrent/tuple'
1717
require 'concurrent/thread_safe/util/xor_shift_random'
1818
require 'concurrent/thread_safe/util/volatile'
1919
require 'concurrent/thread_safe/util/striped64'

lib/concurrent/thread_safe/util/power_of_two_tuple.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require 'concurrent/collection/tuple'
1+
require 'concurrent/tuple'
22

33
module Concurrent
44

0 commit comments

Comments
 (0)