public class ConcurrencyManager
extends java.lang.Object
implements java.io.Serializable
Purpose: To maintain concurrency for a particular task. It is a wrappers of a semaphore that allows recursive waits by a single thread.
Responsibilities:
Modifier and Type | Field and Description |
---|---|
static java.util.Map<java.lang.Thread,DeferredLockManager> |
deferredLockManagers |
Constructor and Description |
---|
ConcurrencyManager()
Initialize the newly allocated instance of this class.
|
Modifier and Type | Method and Description |
---|---|
void |
acquire()
Wait for all threads except the active thread.
|
void |
acquire(boolean forMerge)
Wait for all threads except the active thread.
|
void |
acquireDeferredLock()
Add deferred lock into a hashtable to avoid deadlock
|
boolean |
acquireIfUnownedNoWait(boolean forMerge)
If the activeThread is not set, acquire it and return true.
|
boolean |
acquireNoWait()
If the lock is not acquired already acquire it and return true.
|
boolean |
acquireNoWait(boolean forMerge)
If the lock is not acquired already acquire it and return true.
|
void |
acquireReadLock()
Wait on any writer.
|
boolean |
acquireReadLockNoWait()
If this is acquired return false otherwise acquire readlock and return true
|
boolean |
acquireWithWait(boolean forMerge,
int wait)
If the lock is not acquired already acquire it and return true.
|
void |
checkDeferredLock()
Check the lock state, if locked, acquire and release a deferred lock.
|
void |
checkReadLock()
Check the lock state, if locked, acquire and release a read lock.
|
java.lang.Thread |
getActiveThread()
Return the active thread.
|
static DeferredLockManager |
getDeferredLockManager(java.lang.Thread thread)
Return the deferred lock manager from the thread
|
int |
getDepth()
Return the current depth of the active thread.
|
int |
getNumberOfReaders()
Number of writer that want the lock.
|
int |
getNumberOfWritersWaiting()
Number of writers that want the lock.
|
java.lang.Exception |
getStack() |
boolean |
isAcquired()
Return if a thread has acquire this manager.
|
static boolean |
isBuildObjectOnThreadComplete(java.lang.Thread thread,
java.util.Map recursiveSet)
Check if the deferred locks of a thread are all released
|
boolean |
isLockedByMergeManager()
INTERNAL:
Used byt the refresh process to determine if this concurrency manager is locked by
the merge process.
|
boolean |
isNested()
Return if this manager is within a nested acquire.
|
void |
putDeferredLock(java.lang.Thread thread,
DeferredLockManager lockManager) |
void |
release()
Decrement the depth for the active thread.
|
void |
releaseDeferredLock()
Release the deferred lock.
|
void |
releaseReadLock()
Decrement the number of readers.
|
static DeferredLockManager |
removeDeferredLockManager(java.lang.Thread thread)
Remove the deferred lock manager for the thread
|
void |
setActiveThread(java.lang.Thread activeThread)
Set the active thread.
|
void |
setIsLockedByMergeManager(boolean state)
INTERNAL:
Used by the mergemanager to let the read know not to refresh this object as it is being
loaded by the merge process.
|
static void |
setShouldTrackStack(boolean shouldTrackStack)
INTERNAL:
This can be set during debugging to record the stacktrace when a lock is acquired.
|
void |
setStack(java.lang.Exception stack) |
static boolean |
shouldTrackStack() |
java.lang.String |
toString()
Print the nested depth.
|
void |
transitionToDeferredLock() |
public static java.util.Map<java.lang.Thread,DeferredLockManager> deferredLockManagers
public ConcurrencyManager()
public void acquire() throws ConcurrencyException
ConcurrencyException
public void acquire(boolean forMerge) throws ConcurrencyException
ConcurrencyException
public boolean acquireNoWait() throws ConcurrencyException
ConcurrencyException
public boolean acquireNoWait(boolean forMerge) throws ConcurrencyException
ConcurrencyException
public boolean acquireWithWait(boolean forMerge, int wait) throws ConcurrencyException
ConcurrencyException
public boolean acquireIfUnownedNoWait(boolean forMerge) throws ConcurrencyException
ConcurrencyException
public void acquireDeferredLock() throws ConcurrencyException
ConcurrencyException
public void checkDeferredLock() throws ConcurrencyException
ConcurrencyException
public void checkReadLock() throws ConcurrencyException
ConcurrencyException
public void acquireReadLock() throws ConcurrencyException
ConcurrencyException
public boolean acquireReadLockNoWait()
public java.lang.Thread getActiveThread()
public static DeferredLockManager getDeferredLockManager(java.lang.Thread thread)
public int getDepth()
public int getNumberOfReaders()
public int getNumberOfWritersWaiting()
public boolean isAcquired()
public boolean isLockedByMergeManager()
public static boolean isBuildObjectOnThreadComplete(java.lang.Thread thread, java.util.Map recursiveSet)
public boolean isNested()
public void putDeferredLock(java.lang.Thread thread, DeferredLockManager lockManager)
public void release() throws ConcurrencyException
ConcurrencyException
public void releaseDeferredLock() throws ConcurrencyException
ConcurrencyException
public void releaseReadLock() throws ConcurrencyException
ConcurrencyException
public static DeferredLockManager removeDeferredLockManager(java.lang.Thread thread)
public void setActiveThread(java.lang.Thread activeThread)
public void setIsLockedByMergeManager(boolean state)
public void transitionToDeferredLock()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.Exception getStack()
public void setStack(java.lang.Exception stack)
public static boolean shouldTrackStack()
public static void setShouldTrackStack(boolean shouldTrackStack)
shouldTrackStack
- EclipseLink 2.6.3, "build v20160428-59c81c5" API Reference