Skip to content

Commit

Permalink
Use new TruffleRuby::ConcurrentMap backend for Concurrent::Map
Browse files Browse the repository at this point in the history
  • Loading branch information
wildmaples committed May 7, 2021
1 parent 7b7900a commit 4b0c1b2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
@@ -0,0 +1,14 @@
module Concurrent

# @!visibility private
module Collection

# @!visibility private
class TruffleRubyMapBackend < TruffleRuby::ConcurrentMap
def initialize(options = nil)
options ||= {}
super(initial_capacity: options[:initial_capacity], load_factor: options[:load_factor])
end
end
end
end
9 changes: 7 additions & 2 deletions lib/concurrent-ruby/concurrent/map.rb
Expand Up @@ -16,8 +16,13 @@ module Collection
require 'concurrent/collection/map/mri_map_backend'
MriMapBackend
when Concurrent.on_rbx? || Concurrent.on_truffleruby?
require 'concurrent/collection/map/atomic_reference_map_backend'
AtomicReferenceMapBackend
if defined?(::TruffleRuby::ConcurrentMap)
require 'concurrent/collection/map/truffleruby_map_backend'
TruffleRubyMapBackend
else
require 'concurrent/collection/map/atomic_reference_map_backend'
AtomicReferenceMapBackend
end
else
warn 'Concurrent::Map: unsupported Ruby engine, using a fully synchronized Concurrent::Map implementation'
require 'concurrent/collection/map/synchronized_map_backend'
Expand Down

0 comments on commit 4b0c1b2

Please sign in to comment.