Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

JRuby compiler bug.

To reproduce:
ruby -Ilib -e"require 'thread_safe';c=ThreadSafe::Cache.new;100.times{|i| puts(c.put_if_absent(i,i).inspect)}"
  • Loading branch information...
commit d0a65027c8648571ade389222597c374d9cb1bff 1 parent cc2bdd3
@thedarkone authored
View
6 lib/thread_safe/atomic_reference_cache_backend.rb
@@ -405,12 +405,12 @@ def []=(key, value)
value
end
- def compute_if_absent(key)
+ def compute_if_absent(key, &block)
hash = key_hash(key)
current_table = table || initialize_table
while true
if !(node = current_table.volatile_get(i = current_table.hash_to_index(hash)))
- succeeded, new_value = current_table.try_to_cas_in_computed(i, hash, key) { yield }
+ succeeded, new_value = current_table.try_to_cas_in_computed(i, hash, key, &block)
if succeeded
increment_size
return new_value
@@ -422,7 +422,7 @@ def compute_if_absent(key)
elsif Node.locked_hash?(node_hash)
try_await_lock(current_table, i, node)
else
- succeeded, value = attempt_internal_compute_if_absent(key, hash, current_table, i, node, node_hash) { yield }
+ succeeded, value = attempt_internal_compute_if_absent(key, hash, current_table, i, node, node_hash, &block)
return value if succeeded
end
end
View
2  lib/thread_safe/cache.rb
@@ -9,7 +9,7 @@ module ThreadSafe
ConcurrentCacheBackend =
case defined?(RUBY_ENGINE) && RUBY_ENGINE
- when 'jruby'; JRubyCacheBackend
+ when 'jruby'; AtomicReferenceCacheBackend
when 'ruby'; MriCacheBackend
when 'rbx'; AtomicReferenceCacheBackend
else
Please sign in to comment.
Something went wrong with that request. Please try again.