Sha256: 46f2601791e155e6dc507bcf9f2c720641f1393c518dc6b025a91bf831a7cfaa

Contents?: true

Size: 1.43 KB

Versions: 101

Compression:

Stored size: 1.43 KB

Contents

require 'thread'
require 'concurrent/collection/map/non_concurrent_map_backend'

module Concurrent

  # @!visibility private
  module Collection

    # @!visibility private
    class MriMapBackend < NonConcurrentMapBackend

      def initialize(options = nil, &default_proc)
        super(options, &default_proc)
        @write_lock = Mutex.new
      end

      def []=(key, value)
        @write_lock.synchronize { super }
      end

      def compute_if_absent(key)
        if NULL != (stored_value = @backend.fetch(key, NULL)) # fast non-blocking path for the most likely case
          stored_value
        else
          @write_lock.synchronize { super }
        end
      end

      def compute_if_present(key)
        @write_lock.synchronize { super }
      end

      def compute(key)
        @write_lock.synchronize { super }
      end

      def merge_pair(key, value)
        @write_lock.synchronize { super }
      end

      def replace_pair(key, old_value, new_value)
        @write_lock.synchronize { super }
      end

      def replace_if_exists(key, new_value)
        @write_lock.synchronize { super }
      end

      def get_and_set(key, value)
        @write_lock.synchronize { super }
      end

      def delete(key)
        @write_lock.synchronize { super }
      end

      def delete_pair(key, value)
        @write_lock.synchronize { super }
      end

      def clear
        @write_lock.synchronize { super }
      end
    end
  end
end

Version data entries

101 entries across 101 versions & 15 rubygems

Version Path
harbr-0.1.46 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
harbr-0.1.45 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
harbr-0.1.44 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
harbr-0.1.43 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
harbr-0.1.42 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
harbr-0.1.41 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
harbr-0.1.39 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
harbr-0.1.38 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
harbr-0.1.37 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
honeybadger-5.4.0 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
honeybadger-5.3.0 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
mlh-rubocop-config-1.0.2 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
fablicop-1.10.3 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
fablicop-1.10.2 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
fluent-plugin-google-cloud-logging-on-prem-0.1.0 vendor/ruby/3.1.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
mumukit-content-type-1.12.1 vendor/bundle/ruby/2.7.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
mumukit-content-type-1.12.0 vendor/bundle/ruby/2.7.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
concurrent-ruby-1.2.2 lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb