Sha256: 72a69475f92f21918de51d10c74ba0c837c2bfc1aa04e84131c76f787746a882

Contents?: true

Size: 831 Bytes

Versions: 312

Compression:

Stored size: 831 Bytes

Contents

require 'concurrent/thread_safe/util'
require 'concurrent/tuple'

module Concurrent

  # @!visibility private
  module ThreadSafe

    # @!visibility private
    module Util

      # @!visibility private
      class PowerOfTwoTuple < Concurrent::Tuple

        def initialize(size)
          raise ArgumentError, "size must be a power of 2 (#{size.inspect} provided)" unless size > 0 && size & (size - 1) == 0
          super(size)
        end

        def hash_to_index(hash)
          (size - 1) & hash
        end

        def volatile_get_by_hash(hash)
          volatile_get(hash_to_index(hash))
        end

        def volatile_set_by_hash(hash, value)
          volatile_set(hash_to_index(hash), value)
        end

        def next_in_size_table
          self.class.new(size << 1)
        end
      end
    end
  end
end

Version data entries

312 entries across 287 versions & 56 rubygems

Version Path
harbr-0.1.46 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/thread_safe/util/power_of_two_tuple.rb
harbr-0.1.45 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/thread_safe/util/power_of_two_tuple.rb
harbr-0.1.44 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/thread_safe/util/power_of_two_tuple.rb
harbr-0.1.43 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/thread_safe/util/power_of_two_tuple.rb
harbr-0.1.42 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/thread_safe/util/power_of_two_tuple.rb
harbr-0.1.41 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/thread_safe/util/power_of_two_tuple.rb
harbr-0.1.39 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/thread_safe/util/power_of_two_tuple.rb
harbr-0.1.38 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/thread_safe/util/power_of_two_tuple.rb
harbr-0.1.37 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/thread_safe/util/power_of_two_tuple.rb
honeybadger-5.4.0 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/thread_safe/util/power_of_two_tuple.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/thread_safe/util/power_of_two_tuple.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/thread_safe/util/power_of_two_tuple.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/thread_safe/util/power_of_two_tuple.rb
honeybadger-5.3.0 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/thread_safe/util/power_of_two_tuple.rb
mlh-rubocop-config-1.0.2 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/thread_safe/util/power_of_two_tuple.rb
fablicop-1.10.3 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/thread_safe/util/power_of_two_tuple.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/thread_safe/util/power_of_two_tuple.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/thread_safe/util/power_of_two_tuple.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/thread_safe/util/power_of_two_tuple.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/thread_safe/util/power_of_two_tuple.rb