Class: Roby::Distributed::RingServer

Inherits:
Rinda::RingServer
  • Object
show all
Defined in:
lib/roby/distributed/drb.rb

Overview

Reimplements Rinda::RingServer, removing the tuplespace intermediate and the creation of most threads. This is done for performance reasons.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ts, options = {}) ⇒ RingServer

Added a :bind option



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/roby/distributed/drb.rb', line 30

def initialize(ts, options = {})
    options = validate_options options, :bind => Socket.gethostname, :port => Rinda::Ring_PORT

    @bind = options[:bind]
    @port = options[:port]

    @ts  = ts
    @soc = UDPSocket.new
    @soc.bind options[:bind], options[:port]
    @service = service
end

Instance Attribute Details

#bindObject (readonly)

Returns the value of attribute bind.



27
28
29
# File 'lib/roby/distributed/drb.rb', line 27

def bind
  @bind
end

#portObject (readonly)

Returns the value of attribute port.



27
28
29
# File 'lib/roby/distributed/drb.rb', line 27

def port
  @port
end

Instance Method Details

#closeObject



56
57
58
59
# File 'lib/roby/distributed/drb.rb', line 56

def close
    @service.raise Interrupt, "interrupting RingServer"
    @soc.close
end

#serviceObject



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/roby/distributed/drb.rb', line 42

def service
    Thread.new do
	Thread.current.priority = 0
	begin
	    loop do
		msg = @soc.recv(1024)
		tuple, timeout = Marshal.load(msg)
		tuple[1].call(@ts) rescue nil
	    end
	rescue Interrupt
	end
    end
end