-
-
Save aflatter/6791057 to your computer and use it in GitHub Desktop.
This file contains 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
require 'celluloid' | |
def pusher(condition) | |
sleep 5 | |
condition.signal 'Wibble' | |
end | |
def puller(condition) | |
value = condition.wait | |
puts "Pulled: #{value}" | |
end | |
condition = Celluloid::Condition.new | |
t1 = Thread.new { | |
begin | |
puller(condition) | |
rescue Exception => e | |
puts "Exception raised: #{e.message}\n #{e.backtrace.join("\n ")}" | |
end | |
} | |
t2 = Thread.new { | |
begin | |
pusher(condition) | |
rescue Exception => e | |
puts "Exception raised: #{e.message}\n #{e.backtrace.join("\n ")}" | |
end | |
} | |
t1.join | |
t2.join | |
__END__ | |
$ ruby test.rb | |
Pulled: Wibble | |
D, [2013-10-02T11:12:19.773810 #12311] DEBUG -- : Shutdown completed cleanly |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment