Sha256: 1c1ab2903505fa68e864b104766b4ff9538a0369b4524563b342a177e37a17e8

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

# @api private
# @since 0.2.0
class Qonfig::Settings::Lock
  # @api private
  # @since 0.2.0
  def initialize
    @definition_lock = Mutex.new
    @access_lock = Mutex.new
    @merge_lock = Mutex.new
  end

  # @param instructions [Proc]
  # @return [Object]
  #
  # @api private
  # @since 0.2.0
  def thread_safe_definition(&instructions)
    definition_lock.synchronize(&instructions)
  end

  # @param instructions [Proc]
  # @return [Object]
  #
  # @api private
  # @since 0.2.0
  def thread_safe_access(&instructions)
    access_lock.synchronize(&instructions)
  end

  # @param instructions [Proc]
  # @return [Object]
  #
  # @api private
  # @since 0.2.0
  def thread_safe_merge(&instructions)
    merge_lock.synchronize(&instructions)
  end

  private

  # @return [Mutex]
  #
  # @api private
  # @since 0.2.0
  attr_reader :definition_lock

  # @return [Mutex]
  #
  # @api private
  # @since 0.2.0
  attr_reader :access_lock

  # @return [Mutex]
  #
  # @api private
  # @since 0.2.0
  attr_reader :merge_lock
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
qonfig-0.12.0 lib/qonfig/settings/lock.rb
qonfig-0.11.0 lib/qonfig/settings/lock.rb