Class: Bbq::Spawn::CoordinatedExecutor

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/bbq/spawn.rb

Instance Method Summary collapse

Constructor Details

#initialize(executor, options = {}) ⇒ CoordinatedExecutor

Returns a new instance of CoordinatedExecutor.



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/bbq/spawn.rb', line 32

def initialize(executor, options = {})
  @executor = executor
  @timeout  = options.fetch(:timeout, 10)
  @banner   = options[:banner]
  @host     = options[:host]
  @port     = options[:port]
  @url      = options[:url]

  @reader, @writer = IO.pipe

  @strategy = options[:strategy] || IOStrategy::Squelch.new(@writer)
end

Instance Method Details

#joinObject



51
52
53
54
55
56
57
# File 'lib/bbq/spawn.rb', line 51

def join
  Timeout.timeout(@timeout) do
    wait_for_io       if @banner
    wait_for_socket   if @port and @host
    wait_for_response if @url
  end
end

#startObject



45
46
47
48
49
# File 'lib/bbq/spawn.rb', line 45

def start
  @strategy.run(@executor.io)
  @executor.start
  @strategy.after_run if @strategy.respond_to? :after_run
end