Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Macruby and Rubymotion GCD groups explanation
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
You can’t perform that action at this time.