Sha256: df9a522179e0fc4b5f762676e5e712b481b1847aa577366c83e9695d5ba87570

Contents?: true

Size: 1.26 KB

Versions: 9

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

module Qonfig
  class Settings
    # @api private
    # @since 0.2.0
    class 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
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
qonfig-0.10.0 lib/qonfig/settings/lock.rb
qonfig-0.9.0 lib/qonfig/settings/lock.rb
qonfig-0.8.0 lib/qonfig/settings/lock.rb
qonfig-0.7.0 lib/qonfig/settings/lock.rb
qonfig-0.6.0 lib/qonfig/settings/lock.rb
qonfig-0.5.0 lib/qonfig/settings/lock.rb
qonfig-0.4.0 lib/qonfig/settings/lock.rb
qonfig-0.3.0 lib/qonfig/settings/lock.rb
qonfig-0.2.0 lib/qonfig/settings/lock.rb