Sha256: 89504596979d591c8367eeebf7e71defd0738a73b8c353dbb45af216278efb00

Contents?: true

Size: 852 Bytes

Versions: 2

Compression:

Stored size: 852 Bytes

Contents

# frozen_string_literal: true

module Dynflow
  module DelayedExecutors
    class Abstract
      attr_reader :core

      def initialize(world, options = {})
        @world = world
        @options = options
        @started = false
        spawn
      end

      def started?
        @started
      end

      def start
        @core.ask(:start).tap do
          @started = true
        end
      end

      def terminate
        @core.ask(:terminate!)
      end

      def spawn
        Concurrent::Promises.resolvable_future.tap do |initialized|
          @core = core_class.spawn name: 'delayed-executor',
                                   args: [@world, @options],
                                   initialized: initialized
        end
      end

      private

      def core_class
        raise NotImplementedError
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dynflow-1.9.0 lib/dynflow/delayed_executors/abstract.rb
dynflow-1.8.3 lib/dynflow/delayed_executors/abstract.rb