Skip to content

Instantly share code, notes, and snippets.

@eqdw
Created January 4, 2011 21:29
Show Gist options
  • Save eqdw/765456 to your computer and use it in GitHub Desktop.
Save eqdw/765456 to your computer and use it in GitHub Desktop.
Proof of Concept of Erlang-style hot-swapping in Ruby
$CALLBACK = nil
$i = 0
class HotCode
def self.dispatcher(&block)
while(42)
sleep(0.25)
block.call
if($CALLBACK != block)
block = $CALLBACK
end
end
end
end
$CALLBACK = Proc.new{ puts "old"}
thr = Thread.new{ HotCode.dispatcher &$CALLBACK}
sleep(2)
$CALLBACK = Proc.new{ puts "new"}
thr.join
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment