Skip to content

Instantly share code, notes, and snippets.

@celsodantas
Created October 22, 2016 16:00
Show Gist options
  • Save celsodantas/88933014272dd044d6dbcf646ccf7068 to your computer and use it in GitHub Desktop.
Save celsodantas/88933014272dd044d6dbcf646ccf7068 to your computer and use it in GitHub Desktop.
class Cache
def initialize
@fuck = 0
end
def refresh(from)
puts "[#{from}] #{@fuck}"
@fuck = "given"
end
def print(from)
puts "[#{from}] print fuck: #{@fuck}"
end
end
require 'drb/drb'
URI="druby://localhost:8787"
DRb.start_service(URI, Cache.new)
DRb.thread.run
fork do
rpc = DRbObject.new_with_uri(URI)
rpc.refresh("1")
loop do
sleep 2
rpc.print("1")
end
end
fork do
rpc = DRbObject.new_with_uri(URI)
loop do
sleep 2
rpc.print("2")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment