Class: Flor::UnitExecutor

Inherits:
Executor show all
Defined in:
lib/flor/unit/executor.rb

Instance Attribute Summary collapse

Attributes inherited from Executor

#execution, #hooks, #traps, #unit

Instance Method Summary collapse

Methods inherited from Executor

#conf, #counter, #counter_add, #counter_next, #node, #traps_and_hooks, #trigger_block, #trigger_hook, #trigger_trap, #vars

Constructor Details

#initialize(unit, messages) ⇒ UnitExecutor

Returns a new instance of UnitExecutor.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/flor/unit/executor.rb', line 10

def initialize(unit, messages)

  @exid = messages.first[:exid]

  super(
    unit,
    unit.loader.load_hooks(@exid),
    unit.storage.fetch_traps(@exid),
    unit.storage.load_execution(@exid))

  @messages = messages
    .collect { |m|
      Flor::Storage
        .from_blob(m[:content])
        .tap { |mm| mm['mid'] = m[:id].to_i } }
  @consumed = []

  @alive = true
  @shutdown = false

  @thread = nil
end

Instance Attribute Details

#consumedObject (readonly)

Returns the value of attribute consumed.



8
9
10
# File 'lib/flor/unit/executor.rb', line 8

def consumed
  @consumed
end

#exidObject (readonly)

Returns the value of attribute exid.



7
8
9
# File 'lib/flor/unit/executor.rb', line 7

def exid
  @exid
end

Instance Method Details

#alive?Boolean

Returns:

  • (Boolean)


33
# File 'lib/flor/unit/executor.rb', line 33

def alive?; @alive; end

#runObject



35
36
37
38
39
40
41
# File 'lib/flor/unit/executor.rb', line 35

def run

  @thread = Thread.new { do_run }
#p [ :unit_executor, :thread, @thread.object_id ]

  self
end

#shutdownObject



43
44
45
46
47
# File 'lib/flor/unit/executor.rb', line 43

def shutdown

  @shutdown = true
  @thread.join
end