Class: DBus::Main

Inherits:
Object
  • Object
show all
Defined in:
lib/dbus/bus.rb

Overview

Main event loop class.

Class that takes care of handling message and signal events asynchronously. Note: This is a native implement and therefore does not integrate with a graphical widget set main loop.

Instance Method Summary collapse

Constructor Details

#initializeMain

Create a new main event loop.



725
726
727
# File 'lib/dbus/bus.rb', line 725

def initialize
  @buses = Hash.new
end

Instance Method Details

#<<(bus) ⇒ Object

Add a bus to the list of buses to watch for events.



730
731
732
# File 'lib/dbus/bus.rb', line 730

def <<(bus)
  @buses[bus.socket] = bus
end

#runObject

Run the main loop. This is a blocking call!



735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
# File 'lib/dbus/bus.rb', line 735

def run
  loop do
    ready, dum, dum = IO.select(@buses.keys)
    ready.each do |socket|
      b = @buses[socket]
      begin
        b.update_buffer
      rescue EOFError
        return              # the bus died
      end
      while m = b.pop_message
        b.process(m)
      end
    end
  end
end