Skip to content

Instantly share code, notes, and snippets.

@toretore
Created Jul 11, 2015
Embed
What would you like to do?
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