Class DRb::ExtServManager
In: lib/drb/extservm.rb
Parent: Object

Methods

Included Modules

DRbUndumped MonitorMixin

Attributes

uri  [RW] 

Public Class methods

[Source]

    # File lib/drb/extservm.rb, line 17
17:     def self.command
18:       @@command
19:     end

[Source]

    # File lib/drb/extservm.rb, line 21
21:     def self.command=(cmd)
22:       @@command = cmd
23:     end

[Source]

    # File lib/drb/extservm.rb, line 25
25:     def initialize
26:       super()
27:       @cond = new_cond
28:       @servers = {}
29:       @waiting = []
30:       @queue = Queue.new
31:       @thread = invoke_thread
32:       @uri = nil
33:     end

Public Instance methods

[Source]

    # File lib/drb/extservm.rb, line 47
47:     def regist(name, ro)
48:       synchronize do
49:         @servers[name] = ro
50:         @cond.signal
51:       end
52:       self
53:     end

[Source]

    # File lib/drb/extservm.rb, line 36
36:     def service(name)
37:       synchronize do
38:         while true
39:           server = @servers[name]
40:           return server if server && server.alive?
41:           invoke_service(name)
42:           @cond.wait
43:         end
44:       end
45:     end

[Source]

    # File lib/drb/extservm.rb, line 55
55:     def unregist(name)
56:       synchronize do
57:         @servers.delete(name)
58:       end
59:     end

Private Instance methods

[Source]

    # File lib/drb/extservm.rb, line 71
71:     def invoke_service(name)
72:       @queue.push(name)
73:     end

[Source]

    # File lib/drb/extservm.rb, line 75
75:     def invoke_service_command(name, command)
76:       raise "invalid command. name: #{name}" unless command
77:       synchronize do
78:         return if @servers.include?(name)
79:         @servers[name] = false
80:       end
81:       uri = @uri || DRb.uri
82:       if RUBY_PLATFORM =~ /mswin32/ && /NT/ =~ ENV["OS"]
83:         system(%Q'cmd /c start "ruby" /b #{command} #{uri} #{name}')
84:       else
85:         system("#{command} #{uri} #{name} &")
86:       end
87:     end

[Source]

    # File lib/drb/extservm.rb, line 62
62:     def invoke_thread
63:       Thread.new do
64:         while true
65:           name = @queue.pop
66:           invoke_service_command(name, @@command[name])
67:         end
68:       end
69:     end

[Validate]