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.



667
668
669
# File 'lib/dbus/bus.rb', line 667

def initialize
  @buses = Hash.new
end

Instance Method Details

#<<(bus) ⇒ Object

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



672
673
674
# File 'lib/dbus/bus.rb', line 672

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

#runObject

Run the main loop. This is a blocking call!



677
678
679
680
681
682
683
684
685
686
687
688
# File 'lib/dbus/bus.rb', line 677

def run
  loop do
    ready, dum, dum = IO.select(@buses.keys)
    ready.each do |socket|
      b = @buses[socket]
      b.update_buffer
      while m = b.pop_message
        b.process(m)
      end
    end
  end
end