Sha256: 2f74a5fe44c506aaab3362773b21b759c5b742e47c2bf6dc21d4662aa5ea5478

Contents?: true

Size: 375 Bytes

Versions: 3

Compression:

Stored size: 375 Bytes

Contents

# frozen_string_literal: true

# @api private
# @since 0.1.0
class SmartCore::Container::ArbitraryLock
  # @return [void]
  #
  # @api private
  # @since 0.1.0
  def initialize
    @lock = Mutex.new
  end

  # @param block [Proc]
  # @return [Any]
  #
  # @api private
  # @since 0.1.0
  def thread_safe(&block)
    @lock.owned? ? yield : @lock.synchronize(&block)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
smart_container-0.9.0 lib/smart_core/container/arbitrary_lock.rb
smart_container-0.8.1 lib/smart_core/container/arbitrary_lock.rb
smart_container-0.8.0 lib/smart_core/container/arbitrary_lock.rb