Sha256: 99f67ba54cf06b286a65063791aa9c841bf6a0a448c6b73f6783d7fd91e2991b

Contents?: true

Size: 611 Bytes

Versions: 2

Compression:

Stored size: 611 Bytes

Contents

# frozen_string_literal: true

module Dynflow
  module Middleware::Common
    class Singleton < Middleware
      # Each action tries to acquire its own lock before the action's #plan starts
      def plan(*args)
        action.singleton_lock!
        pass(*args)
      end

      # At the start of #run we try to acquire action's lock unless it already holds it
      # At the end the action tries to unlock its own lock if the execution plan has no
      #   finalize phase
      def run(*args)
        action.singleton_lock! unless action.holds_singleton_lock?
        pass(*args)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dynflow-1.9.0 lib/dynflow/middleware/common/singleton.rb
dynflow-1.8.3 lib/dynflow/middleware/common/singleton.rb