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.
Create a new main event loop.
# File lib/dbus/bus.rb, line 805 def initialize @buses = Hash.new @quitting = false end
Add a bus to the list of buses to watch for events.
# File lib/dbus/bus.rb, line 811 def <<(bus) @buses[bus.socket] = bus end
Quit a running main loop, to be used eg. from a signal handler
# File lib/dbus/bus.rb, line 816 def quit @quitting = true end
Run the main loop. This is a blocking call!
# File lib/dbus/bus.rb, line 821 def run # before blocking, empty the buffers # https://bugzilla.novell.com/show_bug.cgi?id=537401 @buses.each_value do |b| while m = b.pop_message b.process(m) end end while not @quitting and not @buses.empty? ready, dum, dum = IO.select(@buses.keys) ready.each do |socket| b = @buses[socket] begin b.update_buffer rescue EOFError, SystemCallError @buses.delete socket # this bus died next end while m = b.pop_message b.process(m) end end end end