Sha256: 0a797e06f14b3ed9c78690f7cb6869236dc70df254634da5cd45f695f25a688d

Contents?: true

Size: 802 Bytes

Versions: 7

Compression:

Stored size: 802 Bytes

Contents

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.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

7 entries across 7 versions & 1 rubygems

Version Path
dynflow-1.1.6 lib/dynflow/delayed_executors/abstract.rb
dynflow-1.1.5 lib/dynflow/delayed_executors/abstract.rb
dynflow-1.1.4 lib/dynflow/delayed_executors/abstract.rb
dynflow-1.1.3 lib/dynflow/delayed_executors/abstract.rb
dynflow-1.1.2 lib/dynflow/delayed_executors/abstract.rb
dynflow-1.1.1 lib/dynflow/delayed_executors/abstract.rb
dynflow-1.1.0 lib/dynflow/delayed_executors/abstract.rb