diff --git a/lib/process_shared/synchronizable_semaphore.rb b/lib/process_shared/synchronizable_semaphore.rb index f381b37..0a52873 100644 --- a/lib/process_shared/synchronizable_semaphore.rb +++ b/lib/process_shared/synchronizable_semaphore.rb @@ -45,11 +45,9 @@ module ProcessShared # @return [Boolean] +true+ if currently locked def locked? - @sem.try_wait - @sem.post - false - rescue Errno::EAGAIN - true + acquired = try_lock + unlock if acquired + !acquired end # Releases the lock and sleeps timeout seconds if it is given and