Skip to content

Commit

Permalink
Merge pull request #907 from Shopify/truffleruby-map-backend
Browse files Browse the repository at this point in the history
Add new ConcurrentMap backend for TruffleRuby
  • Loading branch information
chrisseaton authored May 7, 2021
2 parents 9b4269e + 4b0c1b2 commit aa83e25
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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 aa83e25

Please sign in to comment.