mirror of
https://github.com/dkam/suo.git
synced 2025-01-29 07:42:43 +00:00
tiny code style improvements
This commit is contained in:
@@ -87,7 +87,6 @@ module Suo
|
|||||||
private
|
private
|
||||||
|
|
||||||
def acquire_lock(key, resources = 1)
|
def acquire_lock(key, resources = 1)
|
||||||
acquisition_token = nil
|
|
||||||
token = SecureRandom.base64(16)
|
token = SecureRandom.base64(16)
|
||||||
|
|
||||||
retry_with_timeout(key) do
|
retry_with_timeout(key) do
|
||||||
@@ -105,14 +104,11 @@ module Suo
|
|||||||
|
|
||||||
newval = serialize_locks(cleared_locks)
|
newval = serialize_locks(cleared_locks)
|
||||||
|
|
||||||
if set(key, newval, cas)
|
return token if set(key, newval, cas)
|
||||||
acquisition_token = token
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
acquisition_token
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def get(key) # rubocop:disable Lint/UnusedMethodArgument
|
def get(key) # rubocop:disable Lint/UnusedMethodArgument
|
||||||
@@ -135,8 +131,8 @@ module Suo
|
|||||||
start = Time.now.to_f
|
start = Time.now.to_f
|
||||||
|
|
||||||
@retry_count.times do
|
@retry_count.times do
|
||||||
now = Time.now.to_f
|
elapsed = Time.now.to_f - start
|
||||||
break if now - start > @options[:acquisition_timeout]
|
break if elapsed >= @options[:acquisition_timeout]
|
||||||
|
|
||||||
synchronize(key) do
|
synchronize(key) do
|
||||||
yield
|
yield
|
||||||
|
|||||||
Reference in New Issue
Block a user