Class: Dynflow::DelayedExecutors::Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/dynflow/delayed_executors/abstract.rb

Direct Known Subclasses

Polling

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(world, options = {}) ⇒ Abstract

Returns a new instance of Abstract.



8
9
10
11
12
13
# File 'lib/dynflow/delayed_executors/abstract.rb', line 8

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

Instance Attribute Details

#coreObject (readonly)

Returns the value of attribute core.



6
7
8
# File 'lib/dynflow/delayed_executors/abstract.rb', line 6

def core
  @core
end

Instance Method Details

#spawnObject



29
30
31
32
33
34
35
# File 'lib/dynflow/delayed_executors/abstract.rb', line 29

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

#startObject



19
20
21
22
23
# File 'lib/dynflow/delayed_executors/abstract.rb', line 19

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

#started?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/dynflow/delayed_executors/abstract.rb', line 15

def started?
  @started
end

#terminateObject



25
26
27
# File 'lib/dynflow/delayed_executors/abstract.rb', line 25

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