Class: DRb::ExtServManager
- Inherits:
-
Object
- Object
- DRb::ExtServManager
- Includes:
- DRbUndumped
- Defined in:
- lib/drb/extservm.rb
Constant Summary collapse
- @@command =
{}
Instance Attribute Summary collapse
-
#uri ⇒ Object
Returns the value of attribute uri.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ ExtServManager
constructor
A new instance of ExtServManager.
- #regist(name, ro) ⇒ Object
- #service(name) ⇒ Object
- #unregist(name) ⇒ Object
Methods included from DRbUndumped
Constructor Details
#initialize ⇒ ExtServManager
Returns a new instance of ExtServManager.
23 24 25 26 27 28 29 |
# File 'lib/drb/extservm.rb', line 23 def initialize @servers = {} @waiting = [] @queue = Queue.new @thread = invoke_thread @uri = nil end |
Instance Attribute Details
#uri ⇒ Object
Returns the value of attribute uri
30 31 32 |
# File 'lib/drb/extservm.rb', line 30 def uri @uri end |
Class Method Details
.command ⇒ Object
15 16 17 |
# File 'lib/drb/extservm.rb', line 15 def self.command @@command end |
.command=(cmd) ⇒ Object
19 20 21 |
# File 'lib/drb/extservm.rb', line 19 def self.command=(cmd) @@command = cmd end |
Instance Method Details
#regist(name, ro) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/drb/extservm.rb', line 43 def regist(name, ro) ary = nil Thread.exclusive do @servers[name] = ro ary = @waiting @waiting = [] end ary.each do |th| begin th.run rescue ThreadError end end self end |
#service(name) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/drb/extservm.rb', line 32 def service(name) while true server = nil Thread.exclusive do server = @servers[name] if @servers[name] end return server if server && server.alive? invoke_service(name) end end |
#unregist(name) ⇒ Object
59 60 61 62 63 |
# File 'lib/drb/extservm.rb', line 59 def unregist(name) Thread.exclusive do @servers.delete(name) end end |