Class: Phobos::CLI::Runner
- Inherits:
-
Object
- Object
- Phobos::CLI::Runner
- Defined in:
- lib/phobos/cli/runner.rb
Constant Summary collapse
- SIGNALS =
i( INT TERM QUIT ).freeze
Instance Method Summary collapse
-
#initialize ⇒ Runner
constructor
A new instance of Runner.
- #run! ⇒ Object
Constructor Details
#initialize ⇒ Runner
Returns a new instance of Runner.
7 8 9 10 11 |
# File 'lib/phobos/cli/runner.rb', line 7 def initialize @signal_queue = [] @reader, @writer = IO.pipe @executor = Phobos::Executor.new end |
Instance Method Details
#run! ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/phobos/cli/runner.rb', line 13 def run! setup_signals executor.start loop do case signal_queue.pop when *SIGNALS executor.stop break else ready = IO.select([reader, writer]) # drain the self-pipe so it won't be returned again next time reader.read_nonblock(1) if ready[0].include?(reader) end end end |