module WoolenCommon::DrbServerHelper
Public Class Methods
server_init(me='127.0.0.1')
click to toggle source
# File lib/woolen_common/drb_helper.rb, line 52 def server_init(me='127.0.0.1') me_drb_addr = ip_or_iport_with_default(me, SERVER_DEFAULT_PORT) @worker_connect_array = [] @worker_connect_array_mutex = Mutex.new debug "server need to start #{me_drb_addr}" @me_service = start_service(me_drb_addr,self) end
Public Instance Methods
on_one_worker_connect(worker_ip)
click to toggle source
# File lib/woolen_common/drb_helper.rb, line 60 def on_one_worker_connect(worker_ip) debug "get one the worker #{worker_ip}" worker_connect_str = ip_or_iport_with_default worker_ip,CLIENT_DEFAULT_PORT # debug "connect str #{worker_connect_str}" worker_connect = get_drb_connect_obj worker_connect_str worker_id = 0 @worker_connect_array_mutex.synchronize do @worker_connect_array << worker_connect worker_id = @worker_connect_array.length end worker_id end
wait_until_stopped()
click to toggle source
需要阻塞的时候的阻塞函数
# File lib/woolen_common/drb_helper.rb, line 74 def wait_until_stopped puts 'Flow replay worker started. Press ENTER or c-C to stop it' $stdout.flush begin STDIN.gets rescue Interrupt puts "Interrupt" end end
Private Instance Methods
server_init(me='127.0.0.1')
click to toggle source
# File lib/woolen_common/drb_helper.rb, line 52 def server_init(me='127.0.0.1') me_drb_addr = ip_or_iport_with_default(me, SERVER_DEFAULT_PORT) @worker_connect_array = [] @worker_connect_array_mutex = Mutex.new debug "server need to start #{me_drb_addr}" @me_service = start_service(me_drb_addr,self) end