Method: Tap::App#run
- Defined in:
- lib/tap/app.rb
#run ⇒ Object
Sequentially executes each enqued job (a [task, input] pair). A run continues until the queue is empty.
Run checks the state of self before executing a task. If the state changes from RUN, the following behaviors result:
STOP No more tasks will be executed; the current task
will continute to completion.
TERMINATE No more tasks will be executed and the currently
running task will be discontinued as described in
terminate.
Calls to run when the state is not READY do nothing and return immediately.
Returns self.
500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 |
# File 'lib/tap/app.rb', line 500 def run synchronize do return self unless state == State::READY @state = State::RUN end begin while state == State::RUN break unless job = queue.deq exe(*job) end rescue(TerminateError) # gracefully fail for termination errors queue.unshift(*job) ensure synchronize { @state = State::READY } end self end |