Created
July 11, 2015 21:15
-
-
Save toretore/bab608e6814d4d3ae49d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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