Sha256: acb2a5c374ff243fecbf6d2c5fcd968f44dbd36a957c55961c3e419e4835d0fa

Contents?: true

Size: 1.73 KB

Versions: 89

Compression:

Stored size: 1.73 KB

Contents

require 'concurrent/utility/engine'
require 'concurrent/thread_safe/util'

module Concurrent

  # @!macro concurrent_hash
  #
  #   A thread-safe subclass of Hash. This version locks against the object
  #   itself for every method call, ensuring only one thread can be reading
  #   or writing at a time. This includes iteration methods like `#each`,
  #   which takes the lock repeatedly when reading an item.
  #
  #   @see http://ruby-doc.org/core/Hash.html Ruby standard library `Hash`

  # @!macro internal_implementation_note
  HashImplementation = case
                       when Concurrent.on_cruby?
                         # Hash is thread-safe in practice because CRuby runs
                         # threads one at a time and does not do context
                         # switching during the execution of C functions.
                         ::Hash

                       when Concurrent.on_jruby?
                         require 'jruby/synchronized'

                         class JRubyHash < ::Hash
                           include JRuby::Synchronized
                         end
                         JRubyHash

                       when Concurrent.on_truffleruby?
                         require 'concurrent/thread_safe/util/data_structures'

                         class TruffleRubyHash < ::Hash
                         end

                         ThreadSafe::Util.make_synchronized_on_truffleruby TruffleRubyHash
                         TruffleRubyHash

                       else
                         warn 'Possibly unsupported Ruby implementation'
                         ::Hash
                       end
  private_constant :HashImplementation

  # @!macro concurrent_hash
  class Hash < HashImplementation
  end

end

Version data entries

89 entries across 89 versions & 10 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/hash.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/hash.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/hash.rb
harbr-2.8.1 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/hash.rb
harbr-0.2.10 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/hash.rb
harbr-0.2.9 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/hash.rb
harbr-0.2.8 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/hash.rb
harbr-0.2.7 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/hash.rb
harbr-0.2.6 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/hash.rb
harbr-0.2.5 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/hash.rb
harbr-0.2.4 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/hash.rb
harbr-0.2.3 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/hash.rb
harbr-0.2.2 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/hash.rb
harbr-0.2.1 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/hash.rb
harbr-0.2.0 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/hash.rb
harbr-0.1.99 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/hash.rb
harbr-0.1.98 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/hash.rb
harbr-0.1.97 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/hash.rb
harbr-0.1.96 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/hash.rb
harbr-0.1.95 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/hash.rb