Implement Runner#worker

This commit is contained in:
Thibault Jouan
2015-04-17 21:23:10 +00:00
parent 887c66a6f7
commit fa03cd736a
2 changed files with 39 additions and 0 deletions

View File

@@ -54,6 +54,24 @@ module Uh
end
end
def worker
@worker ||= Workers.build(*(@env.worker)).tap do |w|
w.on_read do
@env.log_debug 'Processing pending events'
@manager.handle_pending_events
end
w.on_read_next do
@env.log_debug 'Processing next event'
@manager.handle_next_event
end
w.on_timeout do |*args|
@env.log_debug "Worker timeout: #{args.inspect}"
@env.log_debug 'Flushing X output buffer'
@manager.flush
end
end
end
def run_until &block
manager.handle_pending_events until block.call
end