@InterfaceAudience.Private public class IdReadWriteLockWithObjectPool<T> extends IdReadWriteLock<T>
Modifier and Type | Class and Description |
---|---|
static class |
IdReadWriteLockWithObjectPool.ReferenceType |
Modifier and Type | Field and Description |
---|---|
private ObjectPool<T,ReentrantReadWriteLock> |
lockPool
The pool to get entry from, entries are mapped by
Reference and will be automatically
garbage-collected by JVM |
private static int |
NB_CONCURRENT_LOCKS |
private IdReadWriteLockWithObjectPool.ReferenceType |
refType |
Constructor and Description |
---|
IdReadWriteLockWithObjectPool() |
IdReadWriteLockWithObjectPool(IdReadWriteLockWithObjectPool.ReferenceType referenceType)
Constructor of IdReadWriteLockWithObjectPool
|
Modifier and Type | Method and Description |
---|---|
private void |
gc() |
ReentrantReadWriteLock |
getLock(T id)
Get the ReentrantReadWriteLock corresponding to the given id
|
IdReadWriteLockWithObjectPool.ReferenceType |
getReferenceType() |
(package private) int |
purgeAndGetEntryPoolSize()
For testing
|
waitForWaiters
private static final int NB_CONCURRENT_LOCKS
private final ObjectPool<T,ReentrantReadWriteLock> lockPool
Reference
and will be automatically
garbage-collected by JVMprivate final IdReadWriteLockWithObjectPool.ReferenceType refType
public IdReadWriteLockWithObjectPool()
public IdReadWriteLockWithObjectPool(IdReadWriteLockWithObjectPool.ReferenceType referenceType)
referenceType
- type of the reference used in lock pool, IdReadWriteLockWithObjectPool.ReferenceType.WEAK
by
default. Use IdReadWriteLockWithObjectPool.ReferenceType.SOFT
if the key set is limited and the
locks will be reused with a high frequencypublic ReentrantReadWriteLock getLock(T id)
getLock
in class IdReadWriteLock<T>
id
- an arbitrary number to identify the lockint purgeAndGetEntryPoolSize()
private void gc()
public IdReadWriteLockWithObjectPool.ReferenceType getReferenceType()
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.