lib/suo/client/base.rb in suo-0.3.1 vs lib/suo/client/base.rb in suo-0.3.2
- old
+ new
@@ -24,12 +24,12 @@
@key = key
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
yield
ensure
@@ -93,11 +93,11 @@
private
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
if val.nil?