Sha256: a9198cb8799b5466169c1e88e56cb2f64c8901901dfa88dbf9b192adb878ca92

Contents?: true

Size: 612 Bytes

Versions: 2

Compression:

Stored size: 612 Bytes

Contents

# frozen_string_literal: true

require 'sync'

module FiniteMachine
  # Mixin to provide lock to a {Threadable}
  #
  # @api private
  module TwoPhaseLock
    # Create synchronization lock
    #
    # @return [Sync]
    #
    # @api private
    def sync
      @sync = Sync.new
    end

    # Synchronize given block of code
    #
    # @param [Symbol] mode
    #   the lock mode out of :SH, :EX, :UN
    #
    # @return [nil]
    #
    # @api private
    def synchronize(mode, &block)
      sync.synchronize(mode, &block)
    end

    module_function :sync, :synchronize
  end # TwoPhaseLock
end # FiniteMachine

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
finite_machine-0.12.1 lib/finite_machine/two_phase_lock.rb
finite_machine-0.12.0 lib/finite_machine/two_phase_lock.rb