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

public Class RecursiveLockImpl01Unfairish

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
Known Direct Subclasses
jogamp.common.util.locks.RecursiveThreadGroupLockImpl01Unfairish
Imports
java.util.List, java.util.concurrent.locks.AbstractOwnableSynchronizer, com.jogamp.common.util.locks.RecursiveLock

Reentrance locking toolkit, impl a non-complete fair FIFO scheduler.

Fair scheduling is not guaranteed due to the usage of Object#notify(), however new lock-applicants will wait if queue is not empty for lock() and tryLock(timeout>0).

Sync object extends AbstractOwnableSynchronizer, hence monitoring is possible.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv static interface

Field Summary

Modifier and TypeField and Description
protected final RecursiveLockImpl01Unfairish.Sync

Constructor Summary

AccessConstructor and Description
public
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.
pack-priv final String
pack-priv 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 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
protected final RecursiveLockImpl01Unfairish.Sync sync

Constructor Detail

RecursiveLockImpl01Unfairishback to summary
public RecursiveLockImpl01Unfairish(final RecursiveLockImpl01Unfairish.Sync sync)
RecursiveLockImpl01Unfairishback to summary
public RecursiveLockImpl01Unfairish()

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
pack-priv final String syncName()
threadNameback to summary
pack-priv 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 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

pack-priv Class RecursiveLockImpl01Unfairish.SingleThreadSync

extends AbstractOwnableSynchronizer
implements Sync
Class Inheritance
All Implemented Interfaces
jogamp.common.util.locks.RecursiveLockImpl01Unfairish.Sync
Known Direct Subclasses
jogamp.common.util.locks.RecursiveThreadGroupLockImpl01Unfairish.ThreadGroupSync
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

private int
qsz

queue size of waiting threads

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
public final void
public final int
public final Throwable
public final Thread
public final int
public void
public final void
public boolean
public final void
public final void
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

qszback to summary
private int qsz

queue size of waiting threads

Constructor Detail

SingleThreadSyncback to summary
pack-priv SingleThreadSync()

Method Detail

decrHoldCountback to summary
public void decrHoldCount(final Thread t)

Implements jogamp.common.util.locks.RecursiveLockImpl01Unfairish.Sync.decrHoldCount.

Annotations
@Override
decrQSzback to summary
public final void decrQSz()

Implements jogamp.common.util.locks.RecursiveLockImpl01Unfairish.Sync.decrQSz.

Annotations
@Override
getHoldCountback to summary
public final int getHoldCount()

Implements jogamp.common.util.locks.RecursiveLockImpl01Unfairish.Sync.getHoldCount.

Annotations
@Override
getLockedStackback to summary
public final Throwable getLockedStack()

Implements jogamp.common.util.locks.RecursiveLockImpl01Unfairish.Sync.getLockedStack.

Annotations
@Override
getOwnerback to summary
public final Thread getOwner()

Implements jogamp.common.util.locks.RecursiveLockImpl01Unfairish.Sync.getOwner.

Annotations
@Override
getQSzback to summary
public final int getQSz()

Implements jogamp.common.util.locks.RecursiveLockImpl01Unfairish.Sync.getQSz.

Annotations
@Override
incrHoldCountback to summary
public void incrHoldCount(final Thread t)

Implements jogamp.common.util.locks.RecursiveLockImpl01Unfairish.Sync.incrHoldCount.

Annotations
@Override
incrQSzback to summary
public final void incrQSz()

Implements jogamp.common.util.locks.RecursiveLockImpl01Unfairish.Sync.incrQSz.

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

Implements jogamp.common.util.locks.RecursiveLockImpl01Unfairish.Sync.isOwner.

Annotations
@Override
setLockedStackback to summary
public final void setLockedStack(final Throwable s)

Implements jogamp.common.util.locks.RecursiveLockImpl01Unfairish.Sync.setLockedStack.

Annotations
@Override
setOwnerback to summary
public final void setOwner(final Thread t)

Implements jogamp.common.util.locks.RecursiveLockImpl01Unfairish.Sync.setOwner.

Annotations
@Override
jogamp.common.util.locks back to summary

pack-priv Interface RecursiveLockImpl01Unfairish.Sync

Known Direct Implementers
jogamp.common.util.locks.RecursiveLockImpl01Unfairish.SingleThreadSync

Method Summary

Modifier and TypeMethod and Description
public void
public void
public int
public Throwable
public Thread
public int
public void
public void
public boolean
public void
public void

Method Detail

decrHoldCountback to summary
public void decrHoldCount(Thread t)
decrQSzback to summary
public void decrQSz()
getHoldCountback to summary
public int getHoldCount()
getLockedStackback to summary
public Throwable getLockedStack()
getOwnerback to summary
public Thread getOwner()
getQSzback to summary
public int getQSz()
incrHoldCountback to summary
public void incrHoldCount(Thread t)
incrQSzback to summary
public void incrQSz()
isOwnerback to summary
public boolean isOwner(Thread t)
setLockedStackback to summary
public void setLockedStack(Throwable s)
setOwnerback to summary
public void setOwner(Thread t)