Top Description Inners Fields Constructors Methods
jogamp.common.util.locks

public Class RecursiveLockImpl01CompleteFair

extends Object
implements RecursiveLock
Class Inheritance
All Implemented Interfaces
com.jogamp.common.util.locks.RecursiveLock, com.jogamp.common.util.locks.ThreadLock, com.jogamp.common.util.locks.Lock
Imports
java.util.ArrayList, .List, java.util.concurrent.locks.AbstractOwnableSynchronizer, com.jogamp.common.util.SourcedInterruptedException, com.jogamp.common.util.locks.RecursiveLock

Reentrance locking toolkit, impl a complete fair FIFO scheduler

Sync object extends AbstractOwnableSynchronizer, hence monitoring is possible.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class

Field Summary

Modifier and TypeField and Description
private final RecursiveLockImpl01CompleteFair.Sync

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public final int
getHoldCount()

Implements com.jogamp.common.util.locks.RecursiveLock.getHoldCount.

Return the number of locks issued to this lock by the same thread.
public final Throwable
getLockedStack()

Returns the Throwable instance generated when this lock was taken the 1st time and if com.jogamp.common.util.locks.Lock#DEBUG is turned on, otherwise it returns always null.

public final Thread
public final int
public final boolean
public final boolean
isLockedByOtherThread()

Implements com.jogamp.common.util.locks.ThreadLock.isLockedByOtherThread.

Query whether the lock is hold by the a thread other than the current thread.
public final boolean
isOwner(final Thread thread)

Implements com.jogamp.common.util.locks.ThreadLock.isOwner.

Query whether the lock is hold by the given thread.
public final void
lock()

Implements com.jogamp.common.util.locks.Lock.lock.

Blocking until the lock is acquired by this Thread or TIMEOUT is reached.
private final String
private final String
threadName(final Thread t)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public final boolean
tryLock(long
Maximum time in ms to wait to acquire the lock. If this value is zero, the call returns immediately either without being able to acquire the lock, or with acquiring the lock directly while ignoring any scheduling order.
timeout
)

Implements com.jogamp.common.util.locks.Lock.tryLock.

Blocking until the lock is acquired by this Thread or maxwait in ms is reached.
public final void
unlock()

Implements com.jogamp.common.util.locks.Lock.unlock.

Release the lock.
public final void
unlock(final Runnable taskAfterUnlockBeforeNotify)

Implements com.jogamp.common.util.locks.ThreadLock.unlock.

Execute the Runnable taskAfterUnlockBeforeNotify while holding the exclusive lock.
public final void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

syncback to summary
private final RecursiveLockImpl01CompleteFair.Sync sync

Constructor Detail

RecursiveLockImpl01CompleteFairback to summary
public RecursiveLockImpl01CompleteFair()

Method Detail

getHoldCountback to summary
public final int getHoldCount()

Implements com.jogamp.common.util.locks.RecursiveLock.getHoldCount.

Doc from com.jogamp.common.util.locks.RecursiveLock.getHoldCount.

Return the number of locks issued to this lock by the same thread.

  • A hold count of 0 identifies this lock as unlocked.
  • A hold count of 1 identifies this lock as locked.
  • A hold count of > 1 identifies this lock as recursively lock.
Annotations
@Override
getLockedStackback to summary
public final Throwable getLockedStack()

Returns the Throwable instance generated when this lock was taken the 1st time and if com.jogamp.common.util.locks.Lock#DEBUG is turned on, otherwise it returns always null.

See Also
com.jogamp.common.util.locks.Lock#DEBUG
getOwnerback to summary
public final Thread getOwner()

Implements com.jogamp.common.util.locks.ThreadLock.getOwner.

Returns:Thread

Doc from com.jogamp.common.util.locks.ThreadLock.getOwner.

the Thread owning this lock if locked, otherwise null

Annotations
@Override
getQueueLengthback to summary
public final int getQueueLength()

Implements com.jogamp.common.util.locks.RecursiveLock.getQueueLength.

Annotations
@Override
isLockedback to summary
public final boolean isLocked()

Implements com.jogamp.common.util.locks.Lock.isLocked.

Doc from com.jogamp.common.util.locks.Lock.isLocked.

Query if locked

Annotations
@Override
isLockedByOtherThreadback to summary
public final boolean isLockedByOtherThread()

Implements com.jogamp.common.util.locks.ThreadLock.isLockedByOtherThread.

Doc from com.jogamp.common.util.locks.ThreadLock.isLockedByOtherThread.

Query whether the lock is hold by the a thread other than the current thread.

Annotations
@Override
isOwnerback to summary
public final boolean isOwner(final Thread thread)

Implements com.jogamp.common.util.locks.ThreadLock.isOwner.

Doc from com.jogamp.common.util.locks.ThreadLock.isOwner.

Query whether the lock is hold by the given thread.

Annotations
@Override
lockback to summary
public final void lock()

Implements com.jogamp.common.util.locks.Lock.lock.

Doc from com.jogamp.common.util.locks.Lock.lock.

Blocking until the lock is acquired by this Thread or TIMEOUT is reached.

Annotations
@Override
syncNameback to summary
private final String syncName()
threadNameback to summary
private final String threadName(final Thread t)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
tryLockback to summary
public final boolean tryLock(long timeout) throws InterruptedException

Implements com.jogamp.common.util.locks.Lock.tryLock.

Doc from com.jogamp.common.util.locks.Lock.tryLock.

Blocking until the lock is acquired by this Thread or maxwait in ms is reached.

Parameters
timeout:long

Maximum time in ms to wait to acquire the lock. If this value is zero, the call returns immediately either without being able to acquire the lock, or with acquiring the lock directly while ignoring any scheduling order.

Returns:boolean

true if the lock has been acquired within maxwait, otherwise false

Annotations
@Override
unlockback to summary
public final void unlock()

Implements com.jogamp.common.util.locks.Lock.unlock.

Doc from com.jogamp.common.util.locks.Lock.unlock.

Release the lock.

Annotations
@Override
unlockback to summary
public final void unlock(final Runnable taskAfterUnlockBeforeNotify)

Implements com.jogamp.common.util.locks.ThreadLock.unlock.

Doc from com.jogamp.common.util.locks.ThreadLock.unlock.

Execute the Runnable taskAfterUnlockBeforeNotify while holding the exclusive lock.

Then release the lock.

Annotations
@Override
validateLockedback to summary
public final void validateLocked() throws RuntimeException

Implements com.jogamp.common.util.locks.ThreadLock.validateLocked.

Annotations
@Override
Exceptions
RuntimeException:

Doc from com.jogamp.common.util.locks.ThreadLock.validateLocked.

if current thread does not hold the lock

jogamp.common.util.locks back to summary

private Class RecursiveLockImpl01CompleteFair.Sync

extends AbstractOwnableSynchronizer
Class Inheritance
Annotations
@SuppressWarnings:serial

Field Summary

Modifier and TypeField and Description
private int
holdCount

lock count by same thread

private Throwable
lockedStack

stack trace of the lock, only used if DEBUG

pack-priv final ArrayList<RecursiveLockImpl01CompleteFair.WaitingThread>
queue

waiting thread queue

Constructor Summary

AccessConstructor and Description
private
Sync()

Method Summary

Modifier and TypeMethod and Description
private final Thread
private final void
private final void
setOwner(final Thread t)

Inherited from java.util.concurrent.locks.AbstractOwnableSynchronizer:
getExclusiveOwnerThreadsetExclusiveOwnerThread

Field Detail

holdCountback to summary
private int holdCount

lock count by same thread

lockedStackback to summary
private Throwable lockedStack

stack trace of the lock, only used if DEBUG

queueback to summary
pack-priv final ArrayList<RecursiveLockImpl01CompleteFair.WaitingThread> queue

waiting thread queue

Constructor Detail

Syncback to summary
private Sync()

Method Detail

getOwnerback to summary
private final Thread getOwner()
setLockedStackback to summary
private final void setLockedStack(final Throwable s)
setOwnerback to summary
private final void setOwner(final Thread t)
jogamp.common.util.locks back to summary

private Class RecursiveLockImpl01CompleteFair.WaitingThread

extends Object
Class Inheritance
  • java.lang.Object
  • jogamp.common.util.locks.RecursiveLockImpl01CompleteFair.WaitingThread

Field Summary

Modifier and TypeField and Description
pack-priv boolean
pack-priv final Thread

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

signaledByUnlockback to summary
pack-priv boolean signaledByUnlock
threadback to summary
pack-priv final Thread thread

Constructor Detail

WaitingThreadback to summary
pack-priv WaitingThread(final Thread t)