public class InterProcessSemaphoreMutex extends Object implements InterProcessLock
Constructor and Description |
---|
InterProcessSemaphoreMutex(CuratorFramework client,
String path) |
Modifier and Type | Method and Description |
---|---|
void |
acquire()
Acquire the mutex - blocking until it's available.
|
boolean |
acquire(long time,
TimeUnit unit)
Acquire the mutex - blocks until it's available or the given time expires.
|
boolean |
isAcquiredInThisProcess()
Returns true if the mutex is acquired by a thread in this JVM
|
void |
release()
Perform one release of the mutex.
|
public InterProcessSemaphoreMutex(CuratorFramework client, String path)
client
- the clientpath
- path for the lockpublic void acquire() throws Exception
InterProcessLock
InterProcessLock.release()
acquire
in interface InterProcessLock
Exception
- ZK errors, connection interruptionspublic boolean acquire(long time, TimeUnit unit) throws Exception
InterProcessLock
InterProcessLock.release()
acquire
in interface InterProcessLock
time
- time to waitunit
- time unitException
- ZK errors, connection interruptionspublic void release() throws Exception
NOTE: Unlike other implementations of InterProcessLock.release()
,
this method will NOT throw an exception if it is called on a different thread than the one which acquired the lock.
release
in interface InterProcessLock
Exception
- ZK errors, interruptionspublic boolean isAcquiredInThisProcess()
InterProcessLock
isAcquiredInThisProcess
in interface InterProcessLock
Copyright © 2011–2023 The Apache Software Foundation. All rights reserved.