Class: DBus::Main
- Inherits:
-
Object
- Object
- DBus::Main
- 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
-
#<<(bus) ⇒ Object
Add a bus to the list of buses to watch for events.
-
#initialize ⇒ Main
constructor
Create a new main event loop.
-
#run ⇒ Object
Run the main loop.
Constructor Details
#initialize ⇒ Main
Create a new main event loop.
692 693 694 |
# File 'lib/dbus/bus.rb', line 692 def initialize @buses = Hash.new end |
Instance Method Details
#<<(bus) ⇒ Object
Add a bus to the list of buses to watch for events.
697 698 699 |
# File 'lib/dbus/bus.rb', line 697 def <<(bus) @buses[bus.socket] = bus end |
#run ⇒ Object
Run the main loop. This is a blocking call!
702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 |
# File 'lib/dbus/bus.rb', line 702 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. b.process(m) end end end end |