Class: PikaQue::Launcher
- Inherits:
-
Object
- Object
- PikaQue::Launcher
- Includes:
- Logging
- Defined in:
- lib/pika_que/launcher.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(runnable) ⇒ Launcher
constructor
A new instance of Launcher.
- #launch ⇒ Object
Methods included from Logging
init_logger, logger, #logger, logger=
Constructor Details
#initialize(runnable) ⇒ Launcher
Returns a new instance of Launcher.
5 6 7 |
# File 'lib/pika_que/launcher.rb', line 5 def initialize(runnable) @runnable = runnable end |
Class Method Details
.launch(runnable) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/pika_que/launcher.rb', line 9 def self.launch(runnable) if block_given? new(runnable).launch { yield } else new(runnable).launch end end |
Instance Method Details
#launch ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/pika_que/launcher.rb', line 17 def launch @sig_read, @sig_write = IO.pipe register_signals if block_given? yield else runnable.run end while readable_io = wait_for_signal signal = readable_io.first[0].gets.strip handle_signal(signal) end end |