Sha256: 3f9802a66edf4d94e60243438fb8ef399acbe744d9c7874e7f3b81b08f34f0ec

Contents?: true

Size: 1.24 KB

Versions: 120

Compression:

Stored size: 1.24 KB

Contents

module Concurrent

  # @!visibility private
  # @!macro internal_implementation_note
  class MutexAtomicReference < Synchronization::LockableObject
    include AtomicDirectUpdate
    include AtomicNumericCompareAndSetWrapper
    alias_method :compare_and_swap, :compare_and_set

    # @!macro atomic_reference_method_initialize
    def initialize(value = nil)
      super()
      synchronize { ns_initialize(value) }
    end

    # @!macro atomic_reference_method_get
    def get
      synchronize { @value }
    end
    alias_method :value, :get

    # @!macro atomic_reference_method_set
    def set(new_value)
      synchronize { @value = new_value }
    end
    alias_method :value=, :set

    # @!macro atomic_reference_method_get_and_set
    def get_and_set(new_value)
      synchronize do
        old_value = @value
        @value = new_value
        old_value
      end
    end
    alias_method :swap, :get_and_set

    # @!macro atomic_reference_method_compare_and_set
    def _compare_and_set(old_value, new_value)
      synchronize do
        if @value.equal? old_value
          @value = new_value
          true
        else
          false
        end
      end
    end

    protected

    def ns_initialize(value)
      @value = value
    end
  end
end

Version data entries

120 entries across 106 versions & 25 rubygems

Version Path
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/atomic_reference/mutex_atomic.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/atomic_reference/mutex_atomic.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/atomic_reference/mutex_atomic.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/atomic_reference/mutex_atomic.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/atomic_reference/mutex_atomic.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/atomic_reference/mutex_atomic.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/atomic_reference/mutex_atomic.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/atomic_reference/mutex_atomic.rb
o-concurrent-ruby-1.1.13 lib/concurrent-ruby/concurrent/atomic_reference/mutex_atomic.rb
o-concurrent-ruby-1.1.12 lib/concurrent-ruby/concurrent/atomic_reference/mutex_atomic.rb
o-concurrent-ruby-1.1.11 lib/concurrent-ruby/concurrent/atomic_reference/mutex_atomic.rb
concurrent-ruby-1.1.10 lib/concurrent-ruby/concurrent/atomic_reference/mutex_atomic.rb
ric-0.14.2 vendor/bundle/ruby/2.7.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/atomic_reference/mutex_atomic.rb
ric-0.14.1 vendor/bundle/ruby/2.7.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/atomic_reference/mutex_atomic.rb
phillipug-foodie-0.1.0 .vendor/ruby/3.0.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/atomic_reference/mutex_atomic.rb
ric-0.14.0 vendor/bundle/ruby/2.7.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/atomic_reference/mutex_atomic.rb
vagrant-unbundled-2.2.19.0 vendor/bundle/ruby/3.0.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/atomic_reference/mutex_atomic.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/atomic_reference/mutex_atomic.rb
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/atomic_reference/mutex_atomic.rb
vagrant-unbundled-2.2.18.0 vendor/bundle/ruby/3.0.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/atomic_reference/mutex_atomic.rb