Created
October 21, 2009 13:39
-
-
Save rdp/215107 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# load DRb | |
require 'drb' | |
require 'thread' | |
require 'socket' | |
BasicSocket.do_not_reverse_lookup = true | |
class Synchronized | |
def initialize(this_obj) | |
@self = this_obj | |
@mutex = Mutex.new | |
end | |
def method_missing meth, *args | |
@mutex.synchronize { | |
@self.send(meth, *args) { |*incoming_args| yield(*incoming_args) } | |
} | |
end | |
end | |
# start up the DRb service | |
DRb.start_service nil, Synchronized.new(['line 1', 'line 2']) | |
# We need the uri of the service to connect a client | |
puts DRb.uri | |
DRb.thread.join |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment