Created
November 16, 2019 15:06
-
-
Save havenwood/119e16d7728cb00306739137b30d75a9 to your computer and use it in GitHub Desktop.
Example Async equivalent to code naftilos76's code that phaul is helping with on #ruby IRC: https://gist.github.com/phaul/2b2166c913452f010b1513a8165ab287
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 'async' | |
condition = Async::Condition.new | |
Async do | |
task_one = Async do | |
loop do | |
puts 'task one before waiting' | |
condition.wait | |
end | |
end | |
Async do | |
puts 'task two signalling' | |
condition.signal | |
puts 'still task two' | |
task_one.stop | |
end | |
end | |
#>> task one before waiting | |
#>> task two signalling | |
#>> task one before waiting | |
#>> still task two | |
#=> #<Async::Task:0xcefacedfe (complete)> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment