summaryrefslogtreecommitdiff
path: root/scripts/context/ruby/base/kpse/drb.rb
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/context/ruby/base/kpse/drb.rb')
-rw-r--r--scripts/context/ruby/base/kpse/drb.rb57
1 files changed, 57 insertions, 0 deletions
diff --git a/scripts/context/ruby/base/kpse/drb.rb b/scripts/context/ruby/base/kpse/drb.rb
new file mode 100644
index 000000000..db1ce0eec
--- /dev/null
+++ b/scripts/context/ruby/base/kpse/drb.rb
@@ -0,0 +1,57 @@
+require 'drb'
+require 'base/kpse/trees'
+
+class KpseServer
+
+ attr_accessor :port
+
+ def initialize(port=7000)
+ @port = port
+ end
+
+ def start
+ puts "starting drb service at port #{@port}"
+ DRb.start_service("druby://localhost:#{@port}", KpseTrees.new)
+ trap(:INT) do
+ DRb.stop_service
+ end
+ DRb.thread.join
+ end
+
+ def stop
+ # todo
+ end
+
+end
+
+class KpseClient
+
+ attr_accessor :port
+
+ def initialize(port=7000)
+ @port = port
+ @kpse = nil
+ end
+
+ def start
+ # only needed when callbacks are used / slow, due to Socket::getaddrinfo
+ # DRb.start_service
+ end
+
+ def object
+ @kpse = DRbObject.new(nil,"druby://localhost:#{@port}")
+ end
+
+end
+
+
+# SERVER_URI="druby://localhost:8787"
+#
+# # Start a local DRbServer to handle callbacks.
+# #
+# # Not necessary for this small example, but will be required
+# # as soon as we pass a non-marshallable object as an argument
+# # to a dRuby call.
+# DRb.start_service
+#
+# timeserver = DRbObject.new_with_uri(SERVER_URI)