Created
May 16, 2017 10:36
-
-
Save mikecmpbll/2dd2450e7419f1495b16cede14fc6f06 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
module WithLock | |
def with_lock | |
lock.owned? ? yield : lock.synchronize{ yield } | |
end | |
end | |
class Mutex | |
prepend WithLock | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment