Prototype two workers: blocking and multiplexing

This commit is contained in:
Thibault Jouan
2015-04-17 21:25:00 +00:00
parent 0164b52465
commit 0176ab0010
5 changed files with 89 additions and 0 deletions

18
lib/uh/wm/workers/mux.rb Normal file
View File

@@ -0,0 +1,18 @@
module Uh
module WM
module Workers
class Mux < Base
def initialize timeout: 1
super
@timeout = timeout
end
def work_events
@before_wait.call if @before_wait
if res = select(@ios, [], [], @timeout) then @on_read.call res
else @on_timeout.call if @on_timeout end
end
end
end
end
end