Sha256: 1a8fea073c520fc2f20feec0d4458f87229bcb242690239206e1be1cd9b29da0

Contents?: true

Size: 451 Bytes

Versions: 6

Compression:

Stored size: 451 Bytes

Contents

# frozen_string_literal: true

# @api private
# @since 0.1.0
class Sidekiq::Portal::Lock
  # @return [void]
  #
  # @api private
  # @since 0.1.0
  def initialize
    @lock = Mutex.new
  end

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

  private

  # @return [Mutex]
  #
  # @api private
  # @since 0.1.0
  attr_reader :lock
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sidekiq_portal-0.3.2 lib/portal/lock.rb
sidekiq_portal-0.3.1 lib/portal/lock.rb
sidekiq_portal-0.3.0 lib/portal/lock.rb
sidekiq_portal-0.2.0 lib/portal/lock.rb
sidekiq_portal-0.1.1 lib/portal/lock.rb
sidekiq_portal-0.1.0 lib/portal/lock.rb