Class: Uh::WM::Workers::MultiplexingWorker
Constant Summary
collapse
- DEFAULT_TIMEOUT =
4
Instance Method Summary
collapse
Methods inherited from BaseWorker
#initialize
Instance Method Details
7
8
9
10
|
# File 'lib/uh/wm/workers/multiplexing_worker.rb', line 7
def configure(timeout: DEFAULT_TIMEOUT, on_timeout: nil)
@timeout = timeout
@on_timeout = on_timeout
end
|
#each_event ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/uh/wm/workers/multiplexing_worker.rb', line 17
def each_event
loop do
@display.flush
@logger.debug "select [#{@display_io.fileno}], _, _, #{@timeout}"
rs, _ = IO.select [@display_io], [], [], @timeout
@logger.debug " => #{rs.inspect}"
if rs.nil? || rs.empty?
@on_timeout.call if @on_timeout
else
yield @display.next_event while @display.pending?
end
end
end
|
#setup ⇒ Object
12
13
14
15
|
# File 'lib/uh/wm/workers/multiplexing_worker.rb', line 12
def setup
@display_io = IO.new(@display.fileno)
self
end
|