Top Description Fields Methods
com.jogamp.common.util.locks

public Interface Lock

Known Direct Subinterfaces
com.jogamp.common.util.locks.ThreadLock
Known Direct Implementers
com.jogamp.common.util.locks.SingletonInstance
Imports
jogamp.common.Debug

Specifying a thread blocking lock implementation

Field Summary

Modifier and TypeField and Description
public static final boolean
DEBUG

Enable via the property jogamp.debug.Lock

public static final long
DEFAULT_TIMEOUT

The default TIMEOUT value, of ms

public static final long
TIMEOUT

The TIMEOUT for lock() in ms, defaults to DEFAULT_TIMEOUT.

public static final boolean
TRACE_LOCK

Enable via the property jogamp.debug.Lock.TraceLock

Method Summary

Modifier and TypeMethod and Description
public boolean
isLocked()

Query if locked

public void
lock()

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

public boolean

Returns:

true if the lock has been acquired within maxwait, otherwise false
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
)

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

public void
unlock()

Release the lock.

Field Detail

DEBUGback to summary
public static final boolean DEBUG

Enable via the property jogamp.debug.Lock

DEFAULT_TIMEOUTback to summary
public static final long DEFAULT_TIMEOUT

The default TIMEOUT value, of ms

TIMEOUTback to summary
public static final long TIMEOUT

The TIMEOUT for lock() in ms, defaults to DEFAULT_TIMEOUT.

It can be overridden via the system property jogamp.common.utils.locks.Lock.timeout.

TRACE_LOCKback to summary
public static final boolean TRACE_LOCK

Enable via the property jogamp.debug.Lock.TraceLock

Method Detail

isLockedback to summary
public boolean isLocked()

Query if locked

lockback to summary
public void lock() throws RuntimeException

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

Exceptions
RuntimeException:
in case of TIMEOUT
tryLockback to summary
public boolean tryLock(long timeout) throws InterruptedException

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

unlockback to summary
public void unlock() throws RuntimeException

Release the lock.

Exceptions
RuntimeException:
in case the lock is not acquired by this thread.