Sha256: d9af882277bc9ac9a21025baa5d601a674ae0430723ed55cff4f5326386f2850

Contents?: true

Size: 845 Bytes

Versions: 103

Compression:

Stored size: 845 Bytes

Contents

require 'concurrent/errors'

module Concurrent

  # Define update methods that use direct paths
  #
  # @!visibility private
  # @!macro internal_implementation_note
  module AtomicDirectUpdate
    def update
      true until compare_and_set(old_value = get, new_value = yield(old_value))
      new_value
    end

    def try_update
      old_value = get
      new_value = yield old_value

      return unless compare_and_set old_value, new_value

      new_value
    end

    def try_update!
      old_value = get
      new_value = yield old_value
      unless compare_and_set(old_value, new_value)
        if $VERBOSE
          raise ConcurrentUpdateError, "Update failed"
        else
          raise ConcurrentUpdateError, "Update failed", ConcurrentUpdateError::CONC_UP_ERR_BACKTRACE
        end
      end
      new_value
    end
  end
end

Version data entries

103 entries across 103 versions & 16 rubygems

Version Path
fluent-plugin-nuopenlineage-light-0.1.0 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic_reference/atomic_direct_update.rb
fluent-plugin-openlineage-light-0.1.4 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic_reference/atomic_direct_update.rb
fluent-plugin-openlineage-light-0.1.3 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/atomic_reference/atomic_direct_update.rb
concurrent-ruby-1.3.4 lib/concurrent-ruby/concurrent/atomic_reference/atomic_direct_update.rb
fluent-plugin-openlineage-0.1.0 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/atomic_reference/atomic_direct_update.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/atomic_reference/atomic_direct_update.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/atomic_reference/atomic_direct_update.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/atomic_reference/atomic_direct_update.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/atomic_reference/atomic_direct_update.rb
katalyst-govuk-formbuilder-1.9.2 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/atomic_reference/atomic_direct_update.rb
concurrent-ruby-1.3.3 lib/concurrent-ruby/concurrent/atomic_reference/atomic_direct_update.rb
concurrent-ruby-1.3.2 lib/concurrent-ruby/concurrent/atomic_reference/atomic_direct_update.rb
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.1/lib/concurrent-ruby/concurrent/atomic_reference/atomic_direct_update.rb
concurrent-ruby-1.3.1 lib/concurrent-ruby/concurrent/atomic_reference/atomic_direct_update.rb
concurrent-ruby-1.3.1.pre lib/concurrent-ruby/concurrent/atomic_reference/atomic_direct_update.rb
harbr-2.8.1 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/atomic_reference/atomic_direct_update.rb
mlh-rubocop-config-1.0.3 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.3/lib/concurrent-ruby/concurrent/atomic_reference/atomic_direct_update.rb
concurrent-ruby-1.2.3 lib/concurrent-ruby/concurrent/atomic_reference/atomic_direct_update.rb
harbr-0.2.10 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/atomic_reference/atomic_direct_update.rb
harbr-0.2.9 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/atomic_reference/atomic_direct_update.rb