Class: Uh::WM::Workers::MultiplexingWorker

Inherits:
BaseWorker
  • Object
show all
Defined in:
lib/uh/wm/workers/multiplexing_worker.rb

Constant Summary collapse

DEFAULT_TIMEOUT =
4

Instance Method Summary collapse

Methods inherited from BaseWorker

#initialize

Constructor Details

This class inherits a constructor from Uh::WM::Workers::BaseWorker

Instance Method Details

#configure(timeout: DEFAULT_TIMEOUT) ⇒ Object



7
8
9
# File 'lib/uh/wm/workers/multiplexing_worker.rb', line 7

def configure(timeout: DEFAULT_TIMEOUT)
  @timeout = timeout
end

#each_eventObject



17
18
19
20
21
22
23
24
25
# File 'lib/uh/wm/workers/multiplexing_worker.rb', line 17

def each_event
  loop do
    @logger.debug "select [#{@display_io.fileno}], _, _, #{@timeout}"
    rs, _ = IO.select [@display_io], [], [], @timeout
    @logger.debug " => #{rs.inspect}"
    next if rs.nil? || rs.empty?
    yield @display.next_event while @display.pending?
  end
end

#setupObject



11
12
13
14
15
# File 'lib/uh/wm/workers/multiplexing_worker.rb', line 11

def setup
  @display_io = IO.new(@display.fileno)
  @display.flush
  self
end