Skip to content

Instantly share code, notes, and snippets.

@toretore
Created July 11, 2015 21:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toretore/bab608e6814d4d3ae49d to your computer and use it in GitHub Desktop.
Save toretore/bab608e6814d4d3ae49d to your computer and use it in GitHub Desktop.
class Waiter
def initialize
@m, @cv = Mutex.new, ConditionVariable.new
@signalled = false
end
def wait
@m.synchronize{ @cv.wait(@m) until @signalled; @signalled = false }
end
def signal
@m.synchronize{ @signalled = true; @cv.signal }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment