public interface MultiLevelLock2 extends MultiLevelLock
MultiLevelLock
allows for more flexible
locking including preference and more compatibility modes.LockManager2
,
MultiLevelLock
,
GenericLock
Modifier and Type | Field and Description |
---|---|
static int |
COMPATIBILITY_NONE
Compatibility mode: none reentrant.
|
static int |
COMPATIBILITY_REENTRANT
Compatibility mode: reentrant.
|
static int |
COMPATIBILITY_REENTRANT_AND_SUPPORT
Compatibility mode: reentrant and supporting.
|
static int |
COMPATIBILITY_SUPPORT
Compatibility mode: supporting.
|
Modifier and Type | Method and Description |
---|---|
boolean |
acquire(Object ownerId,
int targetLockLevel,
boolean wait,
int compatibility,
boolean preferred,
long timeoutMSecs)
Tries to acquire a certain lock level on this lock.
|
boolean |
has(Object ownerId,
int lockLevel)
Tests if a certain lock level is owned by an owner.
|
boolean |
test(Object ownerId,
int targetLockLevel,
int compatibility)
Tests if a certain lock level could be acquired.
|
acquire, getLockLevel, release
static final int COMPATIBILITY_NONE
static final int COMPATIBILITY_REENTRANT
static final int COMPATIBILITY_SUPPORT
static final int COMPATIBILITY_REENTRANT_AND_SUPPORT
boolean has(Object ownerId, int lockLevel)
ownerId
- a unique id identifying the entity that wants to check a
certain lock level on this locklockLevel
- the lock level to testtrue
if the lock could be acquired at the time
this method was calledboolean test(Object ownerId, int targetLockLevel, int compatibility)
ownerId
- a unique id identifying the entity that wants to test a
certain lock level on this locktargetLockLevel
- the lock level to acquirecompatibility
- COMPATIBILITY_NONE
if no additional compatibility is
desired (same as reentrant set to false) ,
COMPATIBILITY_REENTRANT
if lock level by the same
owner shall not affect compatibility (same as reentrant set to
true), or COMPATIBILITY_SUPPORT
if lock levels that
are the same as the desired shall not affect compatibility, or
finally COMPATIBILITY_REENTRANT_AND_SUPPORT
which is
a combination of reentrant and supporttrue
if the lock could be acquired at the time
this method was calledboolean acquire(Object ownerId, int targetLockLevel, boolean wait, int compatibility, boolean preferred, long timeoutMSecs) throws InterruptedException
MultiLevelLock.acquire(java.lang.Object, int, boolean, boolean, long)
except that it allows for different compatibility settings. There is an
additional compatibility mode COMPATIBILITY_SUPPORT
that allows
equal lock levels not to interfere with each other. This is like an
additional shared compatibility and useful when you only want to make
sure not to interfer with lowe levels, but are fine with the same.ownerId
- a unique id identifying the entity that wants to acquire a certain lock level on this locktargetLockLevel
- the lock level to acquirewait
- true
if this method shall block when the desired lock level can not be acquiredcompatibility
- COMPATIBILITY_NONE
if no additional compatibility is
desired (same as reentrant set to false) ,
COMPATIBILITY_REENTRANT
if lock level by the same
owner shall not affect compatibility (same as reentrant set to
true), or COMPATIBILITY_SUPPORT
if lock levels that
are the same as the desired shall not affect compatibility, or
finally COMPATIBILITY_REENTRANT_AND_SUPPORT
which is
a combination of reentrant and supportpreferred
- in case this lock request is incompatible with existing ones
and we wait, it shall be granted before other waiting requests
that are not preferredtimeoutMSecs
- if blocking is enabled by the wait
parameter this specifies the maximum wait time in millisecondstrue
if the lock actually was acquiredInterruptedException
- when the thread waiting on this method is interruptedCopyright © 2004-2013 The Apache Software Foundation. All Rights Reserved.