Allow to use custom token for lock

This commit is contained in:
Vokhmin Alexey V
2016-10-05 13:47:10 +03:00
parent a23282dcc6
commit 05661e143c
3 changed files with 11 additions and 4 deletions

View File

@@ -26,8 +26,8 @@ module Suo
super() # initialize Monitor mixin for thread safety
end
def lock
token = acquire_lock
def lock(custom_token = nil)
token = acquire_lock(custom_token)
if block_given? && token
begin
@@ -95,8 +95,8 @@ module Suo
attr_accessor :retry_count
def acquire_lock
token = SecureRandom.base64(16)
def acquire_lock(token = nil)
token ||= SecureRandom.base64(16)
retry_with_timeout do
val, cas = get