summaryrefslogtreecommitdiff
path: root/jni/ruby/lib/drb/extserv.rb
diff options
context:
space:
mode:
authorJari Vetoniemi <jari.vetoniemi@indooratlas.com>2020-03-16 18:49:26 +0900
committerJari Vetoniemi <jari.vetoniemi@indooratlas.com>2020-03-30 00:39:06 +0900
commitfcbf63e62c627deae76c1b8cb8c0876c536ed811 (patch)
tree64cb17de3f41a2b6fef2368028fbd00349946994 /jni/ruby/lib/drb/extserv.rb
Fresh start
Diffstat (limited to 'jni/ruby/lib/drb/extserv.rb')
-rw-r--r--jni/ruby/lib/drb/extserv.rb43
1 files changed, 43 insertions, 0 deletions
diff --git a/jni/ruby/lib/drb/extserv.rb b/jni/ruby/lib/drb/extserv.rb
new file mode 100644
index 0000000..327b553
--- /dev/null
+++ b/jni/ruby/lib/drb/extserv.rb
@@ -0,0 +1,43 @@
+=begin
+ external service
+ Copyright (c) 2000,2002 Masatoshi SEKI
+=end
+
+require 'drb/drb'
+require 'monitor'
+
+module DRb
+ class ExtServ
+ include MonitorMixin
+ include DRbUndumped
+
+ def initialize(there, name, server=nil)
+ super()
+ @server = server || DRb::primary_server
+ @name = name
+ ro = DRbObject.new(nil, there)
+ synchronize do
+ @invoker = ro.regist(name, DRbObject.new(self, @server.uri))
+ end
+ end
+ attr_reader :server
+
+ def front
+ DRbObject.new(nil, @server.uri)
+ end
+
+ def stop_service
+ synchronize do
+ @invoker.unregist(@name)
+ server = @server
+ @server = nil
+ server.stop_service
+ true
+ end
+ end
+
+ def alive?
+ @server ? @server.alive? : false
+ end
+ end
+end