Sha256: 6453d7a9ab1855b3008e87018a82abde34d3bbd53e4583315d1c001bd2e4423f

Contents?: true

Size: 374 Bytes

Versions: 7

Compression:

Stored size: 374 Bytes

Contents

# frozen_string_literal: true

# @api private
# @since 0.1.0
class SmartCore::Container::ArbitaryLock
  # @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

7 entries across 7 versions & 1 rubygems

Version Path
smart_container-0.7.0 lib/smart_core/container/arbitary_lock.rb
smart_container-0.6.0 lib/smart_core/container/arbitary_lock.rb
smart_container-0.5.0 lib/smart_core/container/arbitary_lock.rb
smart_container-0.4.0 lib/smart_core/container/arbitary_lock.rb
smart_container-0.3.0 lib/smart_core/container/arbitary_lock.rb
smart_container-0.2.0 lib/smart_core/container/arbitary_lock.rb
smart_container-0.1.0 lib/smart_core/container/arbitary_lock.rb