linesky 发表于 2011-04-15 00:03

Ruby 使用 DRb 启动远程对象服务

require "drb"
require "drb_observer"

class Ticker
include DRbObservable

def initialize()
    Thread.new { run }
end

def run
    loop do
      price = 10
      print "Current price: #{price}\n"
      notify_observers(Time.now, price)
      sleep 1
    end
end
end

ticker = Ticker.new()

DRb.start_service('druby://localhost:9001', ticker)
puts 'Press to exit.'
gets

2gua 发表于 2011-04-15 08:42

没文字说明,这种习惯不好。
页: [1]
查看完整版本: Ruby 使用 DRb 启动远程对象服务