|
| 1 | +require 'concurrent/constants' |
1 | 2 | require 'concurrent/errors' |
2 | 3 | require 'concurrent/maybe' |
3 | 4 | require 'concurrent/atomic/atomic_reference' |
@@ -139,10 +140,6 @@ class RubyExchanger < AbstractExchanger |
139 | 140 | # not include the arena or the multi-processor spin loops. |
140 | 141 | # http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/util/concurrent/Exchanger.java |
141 | 142 |
|
142 | | - # @!visibility private |
143 | | - NIL_SENTINEL = Object.new |
144 | | - private_constant :NIL_SENTINEL |
145 | | - |
146 | 143 | # @!visibility private |
147 | 144 | class Node < Concurrent::AtomicReference |
148 | 145 | attr_reader :item, :latch |
@@ -249,7 +246,7 @@ def do_exchange(value, timeout) |
249 | 246 | # - Wake the sleeping occupier |
250 | 247 | # - Return the occupier's item |
251 | 248 |
|
252 | | - value = NIL_SENTINEL if value.nil? # The sentinel allows nil to be a valid value |
| 249 | + value = NULL if value.nil? # The sentinel allows nil to be a valid value |
253 | 250 | slot = @slot # Convenience to minimize typing @ |
254 | 251 | me = Node.new(value) # create my node in case I need to occupy |
255 | 252 | end_at = Concurrent.monotonic_time + timeout.to_f # The time to give up |
@@ -282,7 +279,7 @@ def do_exchange(value, timeout) |
282 | 279 | break CANCEL if timeout && Concurrent.monotonic_time >= end_at |
283 | 280 | end |
284 | 281 |
|
285 | | - result == NIL_SENTINEL ? nil : result |
| 282 | + result == NULL ? nil : result |
286 | 283 | end |
287 | 284 | end |
288 | 285 |
|
|
0 commit comments