Created
October 22, 2016 16:00
-
-
Save celsodantas/88933014272dd044d6dbcf646ccf7068 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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