Package alluxio.resource
Class RefCountLockResource
- java.lang.Object
-
- alluxio.resource.LockResource
-
- alluxio.resource.RWLockResource
-
- alluxio.resource.RefCountLockResource
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class RefCountLockResource extends RWLockResource
Reference counted Lock resource, automatically unlocks and decrements the reference count. It contains a lock and a reference count for that lock, and will decrement the lock reference count and unlocking when the resource is closed.
-
-
Field Summary
-
Fields inherited from class alluxio.resource.LockResource
mLock
-
-
Constructor Summary
Constructors Constructor Description RefCountLockResource(java.util.concurrent.locks.ReentrantReadWriteLock lock, LockMode mode, boolean acquireLock, java.util.concurrent.atomic.AtomicInteger refCount, boolean useTryLock)
Creates a new instance ofLockResource
using the given lock and reference counter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Releases the lock and decrement the ref count if a ref counter was provided at construction time.-
Methods inherited from class alluxio.resource.RWLockResource
downgrade
-
Methods inherited from class alluxio.resource.LockResource
hasSameLock
-
-
-
-
Constructor Detail
-
RefCountLockResource
public RefCountLockResource(java.util.concurrent.locks.ReentrantReadWriteLock lock, LockMode mode, boolean acquireLock, java.util.concurrent.atomic.AtomicInteger refCount, boolean useTryLock)
Creates a new instance ofLockResource
using the given lock and reference counter. The reference counter should have been initialized and incremented outside of this class.- Parameters:
lock
- the lock to acquiremode
- the mode to acquire the lock inacquireLock
- whether to lock the lockrefCount
- ref count for the lockuseTryLock
- applicable only if acquireLock is true. Determines whether or not to useLock.tryLock()
orLock.lock()
to acquire the lock
-
-
Method Detail
-
close
public void close()
Releases the lock and decrement the ref count if a ref counter was provided at construction time.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classLockResource
-
-