Slight refactor to share common code path and clarify behavior
This commit is contained in:
parent
49773b66f4
commit
ef3d6958ea
|
@ -45,11 +45,9 @@ module ProcessShared
|
||||||
|
|
||||||
# @return [Boolean] +true+ if currently locked
|
# @return [Boolean] +true+ if currently locked
|
||||||
def locked?
|
def locked?
|
||||||
@sem.try_wait
|
acquired = try_lock
|
||||||
@sem.post
|
unlock if acquired
|
||||||
false
|
!acquired
|
||||||
rescue Errno::EAGAIN
|
|
||||||
true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Releases the lock and sleeps timeout seconds if it is given and
|
# Releases the lock and sleeps timeout seconds if it is given and
|
||||||
|
|
Loading…
Reference in New Issue