Top Description Fields Constructors Methods
jogamp.nativewindow

public Class SharedResourceToolkitLock

extends Object
implements ToolkitLock
Class Inheritance
All Implemented Interfaces
com.jogamp.nativewindow.ToolkitLock
Imports
java.util.Iterator, java.util.concurrent.atomic.AtomicInteger, com.jogamp.nativewindow.ToolkitLock, com.jogamp.common.ExceptionUtils, com.jogamp.common.util.LongObjectHashMap, com.jogamp.common.util.locks.LockFactory, .RecursiveLock

Implementing a shared resource based recursive com.jogamp.nativewindow.ToolkitLock.

A resource handle maybe used within many objects and can be synchronized across threads via an unique instance of SharedResourceToolkitLock.

Implementation holds a synchronized map from handle to reference counted SharedResourceToolkitLock. New elements are added via get(long) if new and removed via dispose() if no more referenced.

Field Summary

Modifier and TypeField and Description
private final long
private static final LongObjectHashMap
private final RecursiveLock
private final AtomicInteger

Constructor Summary

AccessConstructor and Description
private
SharedResourceToolkitLock(final long handle)

Method Summary

Modifier and TypeMethod and Description
public final void
dispose()

Implements com.jogamp.nativewindow.ToolkitLock.dispose.

Dispose this instance.
public static void
public static final SharedResourceToolkitLock
get(final long handle)

public final void
lock()

Implements com.jogamp.nativewindow.ToolkitLock.lock.

Blocking until the lock is acquired by this Thread or a timeout is reached.
public static int

Returns:

number of unclosed EGL Displays.
shutdown
(final boolean verbose)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
private String
public final void
unlock()

Implements com.jogamp.nativewindow.ToolkitLock.unlock.

Release the lock.
public final void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

handleback to summary
private final long handle
handle2Lockback to summary
private static final LongObjectHashMap handle2Lock
lockback to summary
private final RecursiveLock lock
refCountback to summary
private final AtomicInteger refCount

Constructor Detail

SharedResourceToolkitLockback to summary
private SharedResourceToolkitLock(final long handle)

Method Detail

disposeback to summary
public final void dispose()

Implements com.jogamp.nativewindow.ToolkitLock.dispose.

Doc from com.jogamp.nativewindow.ToolkitLock.dispose.

Dispose this instance.

Shall be called when instance is no more required.

This allows implementations sharing a lock via resources to decrease the reference counter.
Annotations
@Override
dumpOpenDisplayConnectionsback to summary
public static void dumpOpenDisplayConnections()
getback to summary
public static final SharedResourceToolkitLock get(final long handle)
lockback to summary
public final void lock()

Implements com.jogamp.nativewindow.ToolkitLock.lock.

Doc from com.jogamp.nativewindow.ToolkitLock.lock.

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

Timeout is implementation specific, if used at all.

Annotations
@Override
shutdownback to summary
public static int shutdown(final boolean verbose)
Returns:int

number of unclosed EGL Displays.

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
toStringImplback to summary
private String toStringImpl()
unlockback to summary
public final void unlock()

Implements com.jogamp.nativewindow.ToolkitLock.unlock.

Doc from com.jogamp.nativewindow.ToolkitLock.unlock.

Release the lock.

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

Implements com.jogamp.nativewindow.ToolkitLock.validateLocked.

Annotations
@Override
Exceptions
RuntimeException:

Doc from com.jogamp.nativewindow.ToolkitLock.validateLocked.

if current thread does not hold the lock