Skip to content

Instantly share code, notes, and snippets.

@seanlilmateus
Created June 4, 2012 16:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seanlilmateus/2869475 to your computer and use it in GitHub Desktop.
Save seanlilmateus/2869475 to your computer and use it in GitHub Desktop.
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