public class CallbackSemaphore extends java.lang.Object implements SyncCallback
SyncCallback
. Client may create one,
then call asynchronous command, and finally wait on blocking method
#tryAcquire()
or acquireDefault(org.eclipse.wst.jsdt.chromium.RelayOk)
.
Class uses symbolic parameter RelayOk
in its methods that suggests that
user should first call some asynchronous method, then pass it to the acquire method.
Modifier and Type | Field and Description |
---|---|
static long |
OPERATION_TIMEOUT_MS |
Constructor and Description |
---|
CallbackSemaphore() |
Modifier and Type | Method and Description |
---|---|
void |
acquireDefault(RelayOk relayOk) |
void |
callbackDone(java.lang.RuntimeException e)
Implementation of
SyncCallback#callbackDone(RuntimeException) . |
boolean |
tryAcquire(long timeout,
java.util.concurrent.TimeUnit unit)
Tries to acquire the semaphore.
|
boolean |
tryAcquireDefault(RelayOk relayOk)
Tries to acquire semaphore with some reasonable default timeout.
|
public static final long OPERATION_TIMEOUT_MS
public boolean tryAcquireDefault(RelayOk relayOk) throws MethodIsBlockingException
relayOk
- symbolic return value from the asynchronous operation that we are waiting for#OPERATION_TIMEOUT_MS
was exceeded and we gave upMethodIsBlockingException
- if called from a callbackpublic void acquireDefault(RelayOk relayOk) throws MethodIsBlockingException
relayOk
- symbolic return value from the asynchronous operation that we are waiting forMethodIsBlockingException
public boolean tryAcquire(long timeout, java.util.concurrent.TimeUnit unit) throws MethodIsBlockingException
MethodIsBlockingException
which is symbolically thrown whenever
someone violates this rule (i.e. invokes this method from a callback).
Though currently nobody actually throws it, such declarations help to
track blocking methods.timeout
was exceeded and we gave upMethodIsBlockingException
- if called from a callbackpublic void callbackDone(java.lang.RuntimeException e)
SyncCallback#callbackDone(RuntimeException)
.callbackDone
in interface SyncCallback
e
- an exception main callback raised or null if none is reportedCopyright (c) IBM Corp. and others 2000, 2016. All Rights Reserved.