instance method exclusive

Ruby on Rails 7.0.10

Since v5.2.8.1

Available in: v5.2.8.1 v6.0.6 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

exclusive(purpose: nil, compatible: [], after_compatible: [], no_wait: false)

Execute the supplied block while holding the Exclusive lock. If no_wait is set and the lock is not immediately available, returns nil without yielding. Otherwise, returns the result of the block.

See start_exclusive for other options.

Parameters

purpose key = nil
compatible key = []
after_compatible key = []
no_wait key = false
Source
# File activesupport/lib/active_support/concurrency/share_lock.rb, line 148
      def exclusive(purpose: nil, compatible: [], after_compatible: [], no_wait: false)
        if start_exclusive(purpose: purpose, compatible: compatible, no_wait: no_wait)
          begin
            yield
          ensure
            stop_exclusive(compatible: after_compatible)
          end
        end
      end

Defined in activesupport/lib/active_support/concurrency/share_lock.rb line 148 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveSupport::Concurrency::ShareLock

Type at least 2 characters to search.

↑↓ navigate · open · esc close