Skip to content

Commit 5ea48b8

Browse files
committed
Fixed namespace issues on Rbx.
1 parent 423797c commit 5ea48b8

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,8 @@ matrix:
2727
- rvm: jruby-head
2828
- rvm: 1.9.3
2929

30+
before_script:
31+
- "echo $JAVA_OPTS"
32+
- "export JAVA_OPTS=-Xmx1024m"
33+
3034
script: RUBYOPT=-w bundle exec rake ci

lib/concurrent/thread_safe/atomic_reference_map_backend.rb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require 'concurrent/thread_safe/util/xor_shift_random'
1+
require 'concurrent/thread_safe/util'
22

33
module Concurrent
44

@@ -88,7 +88,7 @@ module ThreadSafe
8888
# operations (insert, delete, and replace) require locks. We do not want to
8989
# waste the space required to associate a distinct lock object with each bin,
9090
# so instead use the first node of a bin list itself as a lock. Blocking
91-
# support for these locks relies +Util::CheapLockable. However, we also need a
91+
# support for these locks relies +Concurrent::ThreadSafe::Util::CheapLockable. However, we also need a
9292
# +try_lock+ construction, so we overlay these by using bits of the +Node+
9393
# hash field for lock control (see above), and so normally use builtin
9494
# monitors only for blocking and signalling using
@@ -188,7 +188,7 @@ module ThreadSafe
188188
class AtomicReferenceMapBackend
189189

190190
# @!visibility private
191-
class Table < Util::PowerOfTwoTuple
191+
class Table < Concurrent::ThreadSafe::Util::PowerOfTwoTuple
192192
def cas_new_node(i, hash, key, value)
193193
cas(i, nil, Node.new(hash, key, value))
194194
end
@@ -236,19 +236,19 @@ def delete_node_at(i, node, predecessor_node)
236236
#
237237
# @!visibility private
238238
class Node
239-
extend Util::Volatile
239+
extend Concurrent::ThreadSafe::Util::Volatile
240240
attr_volatile :hash, :value, :next
241241

242-
include Util::CheapLockable
242+
include Concurrent::ThreadSafe::Util::CheapLockable
243243

244-
bit_shift = Util::FIXNUM_BIT_SIZE - 2 # need 2 bits for ourselves
244+
bit_shift = Concurrent::ThreadSafe::Util::FIXNUM_BIT_SIZE - 2 # need 2 bits for ourselves
245245
# Encodings for special uses of Node hash fields. See above for explanation.
246246
MOVED = ('10' << ('0' * bit_shift)).to_i(2) # hash field for forwarding nodes
247247
LOCKED = ('01' << ('0' * bit_shift)).to_i(2) # set/tested only as a bit
248248
WAITING = ('11' << ('0' * bit_shift)).to_i(2) # both bits set/tested together
249249
HASH_BITS = ('00' << ('1' * bit_shift)).to_i(2) # usable bits of normal node hash
250250

251-
SPIN_LOCK_ATTEMPTS = Util::CPU_COUNT > 1 ? Util::CPU_COUNT * 2 : 0
251+
SPIN_LOCK_ATTEMPTS = Concurrent::ThreadSafe::Util::CPU_COUNT > 1 ? Concurrent::ThreadSafe::Util::CPU_COUNT * 2 : 0
252252

253253
attr_reader :key
254254

@@ -272,14 +272,14 @@ def initialize(hash, key, value, next_node = nil)
272272
def try_await_lock(table, i)
273273
if table && i >= 0 && i < table.size # bounds check, TODO: why are we bounds checking?
274274
spins = SPIN_LOCK_ATTEMPTS
275-
randomizer = base_randomizer = Util::XorShiftRandom.get
275+
randomizer = base_randomizer = Concurrent::ThreadSafe::Util::XorShiftRandom.get
276276
while equal?(table.volatile_get(i)) && self.class.locked_hash?(my_hash = hash)
277277
if spins >= 0
278278
if (randomizer = (randomizer >> 1)).even? # spin at random
279279
if (spins -= 1) == 0
280280
Thread.pass # yield before blocking
281281
else
282-
randomizer = base_randomizer = Util::XorShiftRandom.xorshift(base_randomizer) if randomizer.zero?
282+
randomizer = base_randomizer = Concurrent::ThreadSafe::Util::XorShiftRandom.xorshift(base_randomizer) if randomizer.zero?
283283
end
284284
end
285285
elsif cas_hash(my_hash, my_hash | WAITING)
@@ -349,14 +349,14 @@ def locked_hash?(hash)
349349

350350
NOW_RESIZING = -1
351351
DEFAULT_CAPACITY = 16
352-
MAX_CAPACITY = Util::MAX_INT
352+
MAX_CAPACITY = Concurrent::ThreadSafe::Util::MAX_INT
353353

354354
# The buffer size for skipped bins during transfers. The
355355
# value is arbitrary but should be large enough to avoid
356356
# most locking stalls during resizes.
357357
TRANSFER_BUFFER_SIZE = 32
358358

359-
extend Util::Volatile
359+
extend Concurrent::ThreadSafe::Util::Volatile
360360
attr_volatile :table, # The array of bins. Lazily initialized upon first insertion. Size is always a power of two.
361361

362362
# Table initialization and resizing control. When negative, the
@@ -368,7 +368,7 @@ def locked_hash?(hash)
368368

369369
def initialize(options = nil)
370370
super()
371-
@counter = Util::Adder.new
371+
@counter = Concurrent::ThreadSafe::Util::Adder.new
372372
initial_capacity = options && options[:initial_capacity] || DEFAULT_CAPACITY
373373
self.size_control = (capacity = table_size_for(initial_capacity)) > MAX_CAPACITY ? MAX_CAPACITY : capacity
374374
end
@@ -747,7 +747,7 @@ def attempt_get_and_set(key, value, hash, current_table, i, node, node_hash)
747747

748748
def initialize_copy(other)
749749
super
750-
@counter = Util::Adder.new
750+
@counter = Concurrent::ThreadSafe::Util::Adder.new
751751
self.table = nil
752752
self.size_control = (other_table = other.table) ? other_table.size : DEFAULT_CAPACITY
753753
self

lib/concurrent/thread_safe/util/striped64.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
require 'concurrent/thread_safe/util/xor_shift_random'
2-
31
module Concurrent
42

53
# @!visibility private

0 commit comments

Comments
 (0)