Skip to content

Commit

Permalink
updated madebysofa url and changed "if success != 0" to "unless success"
Browse files Browse the repository at this point in the history
  • Loading branch information
preadaptation committed Dec 29, 2011
1 parent bf4a55d commit 9f8645e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sample-macruby/Scripts/gcd/sleeping_barber.rb
@@ -1,14 +1,14 @@
# A GCD-based implementation of the sleeping barber problem:
# http://en.wikipedia.org/wiki/Sleeping_barber_problem
# http://www.madebysofa.com/#blog/the_sleeping_barber
# http://www.madebysofa.com/archive/blog/the-sleeping-barber/

waiting_chairs = Dispatch::Queue.new('com.apple.waiting_chairs')
semaphore = Dispatch::Semaphore.new(3)
index = -1
while true
index += 1
success = semaphore.wait(Dispatch::TIME_NOW)
if success != 0
unless success
puts "Customer turned away #{index}"
next
end
Expand Down

0 comments on commit 9f8645e

Please sign in to comment.