Created
June 4, 2012 16:42
-
-
Save seanlilmateus/2869475 to your computer and use it in GitHub Desktop.
Macruby and Rubymotion GCD groups explanation
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
group = Dispatch::Group.new | |
derpina_queue = Dispatch::Queue.concurrent(:high) #Dispatch::Queue.concurrent("com.company.movie_night.get_wine") | |
derp_queue = Dispatch::Queue.concurrent(:default) #Dispatch::Queue.concurrent("com.company.movie_night.get_popcorn") | |
derpina_queue.async(group) do | |
puts "go to wine cellar to get some Bordeaux" | |
i = 0 | |
while i < 99 | |
puts "can't decide which one to drink" | |
i += 1 | |
end | |
end | |
group.notify(derpina_queue) { warn "Derpina is back :-)" } | |
derp_queue.async(group) do | |
puts "go to the kitchen pick some popcorn" | |
i = 0 | |
while i < 9999 | |
puts "damn, I have to make new one" | |
i += 1 | |
end | |
end | |
group.notify(derp_queue) { warn "Derp is back :-)" } | |
group.wait | |
puts "both are back, let's watch the movie" | |
movie.play |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment