Skip to content

Commit

Permalink
Add eventmachine support
Browse files Browse the repository at this point in the history
This code was pinched from mvidner#52.
The original repo for that PR seems to have been deleted.
  • Loading branch information
asppsa committed Jul 13, 2017
1 parent bab904d commit 95e4fd4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/dbus/bus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,13 @@ def glibize
end
end

def eventmachinize
require File.join(File.dirname(File.expand_path(__FILE__)), "loop-em")

conn = ::EventMachine.watch(@message_queue.socket, Loop::EventMachine::Reader, self)
conn.notify_readable = true
end

# FIXME: describe the following names, flags and constants.
# See DBus spec for definition
NAME_FLAG_ALLOW_REPLACEMENT = 0x1
Expand Down
19 changes: 19 additions & 0 deletions lib/dbus/loop-em.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require 'eventmachine'

module DBus
module Loop
module EventMachine
class Reader < ::EventMachine::Connection
def initialize(parent)
@parent = parent
end

def notify_readable
@parent.dispatch_message_queue
rescue EOFError
detach
end
end
end
end
end

0 comments on commit 95e4fd4

Please sign in to comment.