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

public abstract Class SingletonInstance

extends Object
implements Lock
Class Inheritance
All Implemented Interfaces
com.jogamp.common.util.locks.Lock
Known Direct Subclasses
jogamp.common.util.locks.SingletonInstanceFileLock, jogamp.common.util.locks.SingletonInstanceServerSocket
Imports
java.io.File, jogamp.common.util.locks.SingletonInstanceFileLock, .SingletonInstanceServerSocket

Field Summary

Modifier and TypeField and Description
protected static final boolean
private boolean
private final long

Constructor Summary

AccessConstructor and Description
protected
SingletonInstance(final long poll_ms)

Method Summary

Modifier and TypeMethod and Description
public static SingletonInstance
createFileLock(final long poll_ms, final String lockFileBasename)

public static SingletonInstance
createFileLock(final long poll_ms, final File lockFile)

public static SingletonInstance
createServerSocket(final long poll_ms, final int
to be used for this single instance server socket.
portNumber
)

A user shall use ephemeral ports:

  • IANA suggests 49152 to 65535 as "dynamic and/or private ports".
  • Many GNU/Linux kernels use 32768 to 61000.
  • FreeBSD >= 4.6 uses the IANA port range.
  • FreeBSD < 4.6 and BSD use ports 1024 through 4999.
  • Microsoft Windows operating systems through Server 2003 use the range 1025 to 5000
  • Windows Vista, Windows 7, and Server 2008 use the IANA range.
public abstract String
public final long
protected String
infoPrefix(final long currentMillis)

protected String
public synchronized boolean
public synchronized void
lock()

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

Blocking until the lock is acquired by this Thread or TIMEOUT is reached.
public final String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public synchronized 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.
maxwait
)

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

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

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

Release the lock.
protected abstract boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

DEBUGback to summary
protected static final boolean DEBUG

Hides com.jogamp.common.util.locks.Lock.DEBUG.

lockedback to summary
private boolean locked
poll_msback to summary
private final long poll_ms

Constructor Detail

SingletonInstanceback to summary
protected SingletonInstance(final long poll_ms)

Method Detail

createFileLockback to summary
public static SingletonInstance createFileLock(final long poll_ms, final String lockFileBasename)
createFileLockback to summary
public static SingletonInstance createFileLock(final long poll_ms, final File lockFile)
createServerSocketback to summary
public static SingletonInstance createServerSocket(final long poll_ms, final int portNumber)

A user shall use ephemeral ports:

  • IANA suggests 49152 to 65535 as "dynamic and/or private ports".
  • Many GNU/Linux kernels use 32768 to 61000.
  • FreeBSD >= 4.6 uses the IANA port range.
  • FreeBSD < 4.6 and BSD use ports 1024 through 4999.
  • Microsoft Windows operating systems through Server 2003 use the range 1025 to 5000
  • Windows Vista, Windows 7, and Server 2008 use the IANA range.
Parameters
portNumber:int

to be used for this single instance server socket.

getNameback to summary
public abstract String getName()
getPollPeriodback to summary
public final long getPollPeriod()
infoPrefixback to summary
protected String infoPrefix(final long currentMillis)
infoPrefixback to summary
protected String infoPrefix()
isLockedback to summary
public synchronized boolean isLocked()

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

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

Query if locked

Annotations
@Override
lockback to summary
public synchronized void lock() throws RuntimeException

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
Exceptions
RuntimeException:
in case of TIMEOUT
toStringback to summary
public final 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 synchronized boolean tryLock(long maxwait) throws RuntimeException

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
maxwait: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
tryLockImplback to summary
protected abstract boolean tryLockImpl()
unlockback to summary
public void unlock() throws RuntimeException

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

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

Release the lock.

Annotations
@Override
Exceptions
RuntimeException:
in case the lock is not acquired by this thread.
unlockImplback to summary
protected abstract boolean unlockImpl()