### Home Classes Methods

### In Files

- lib/dbus/bus.rb

### Parent

Object

### Methods

- ::new
- #<<
- #quit
- #run

### Files

- README

### Class/Module Index

Quicksearch

- DBus
- DBus::ASessionBus
- DBus::ASystemBus
- DBus::AuthenticationFailed
- DBus::Authenticator
- DBus::Client
- DBus::Connection
- DBus::Connection::NameRequestError
- DBus::DBusCookieSHA1
- DBus::Error
- DBus::ErrorMessage
- DBus::External
- DBus::FormalParameter
- DBus::IncompleteBufferException
- DBus::Interface
- DBus::InterfaceElement
- DBus::IntrospectXMLParser
- DBus::InvalidClassDefinition
- DBus::InvalidDestinationName
- DBus::InvalidIntrospectionData
- DBus::InvalidMethodName
- DBus::InvalidPacketException
- DBus::InvalidParameters
- DBus::Main
- DBus::MatchRule
- DBus::MatchRuleException
- DBus::Message
- DBus::Method
- DBus::MethodNotImplemented
- DBus::MethodReturnMessage
- DBus::Node
- DBus::Object
- DBus::Object::UndefinedInterface
- DBus::PacketMarshaller
- DBus::PacketUnmarshaller
- DBus::ProxyObject
- DBus::ProxyObjectFactory
- DBus::ProxyObjectInterface
- DBus::RemoteBus
- DBus::Service
- DBus::SessionBus
- DBus::Signal
- DBus::SystemBus
- DBus::Type
- DBus::Type::Parser
- DBus::Type::SignatureException
- DBus::Type::Type
- DBus::TypeException
- DBus::UnknownSignal
- Integer

No matching classes.

# DBus::Main

# 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.

### Public Class Methods

new() click to toggle source

Create a new main event loop.

    # File lib/dbus/bus.rb, line 805
    def initialize
      @buses = Hash.new
      @quitting = false
    end

### Public Instance Methods

<<(bus) click to toggle source

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() click to toggle source

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() click to toggle source

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 = IO.select(@buses.keys, [], [], 5) # timeout 5 seconds
        next unless ready # timeout exceeds so continue unless quitting
        ready.first.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

[Validate]

Generated with the Darkfish Rdoc Generator 2.