Skip to content

Instantly share code, notes, and snippets.

@mikecmpbll
Created May 16, 2017 10:36
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 mikecmpbll/2dd2450e7419f1495b16cede14fc6f06 to your computer and use it in GitHub Desktop.
Save mikecmpbll/2dd2450e7419f1495b16cede14fc6f06 to your computer and use it in GitHub Desktop.
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