Sha256: 8431e6c77c2773681e42dfbc660e281da0054832795eaf792352a837752ced3c

Contents?: true

Size: 1.4 KB

Versions: 36

Compression:

Stored size: 1.4 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)
        super(options)
        @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

36 entries across 33 versions & 15 rubygems

Version Path
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
rubypitaya-3.12.5 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
devcycle-ruby-server-sdk-2.0.0 vendor/bundle/ruby/3.0.0/gems/concurrent-ruby-1.2.0/lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
rubypitaya-3.12.4 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
rubypitaya-3.12.3 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
concurrent-ruby-1.2.0 lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
rubypitaya-3.12.2 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
o-concurrent-ruby-1.1.13 lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
o-concurrent-ruby-1.1.12 lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
o-concurrent-ruby-1.1.11 lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
concurrent-ruby-1.1.10 lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
ric-0.14.2 vendor/bundle/ruby/2.7.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
ric-0.14.1 vendor/bundle/ruby/2.7.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
phillipug-foodie-0.1.0 .vendor/ruby/3.0.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
ric-0.14.0 vendor/bundle/ruby/2.7.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
vagrant-unbundled-2.2.19.0 vendor/bundle/ruby/3.0.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/collection/map/mri_map_backend.rb