public class Event<T extends java.lang.Throwable>
extends java.lang.Object
threading.event. The key difference is that a
waiter may be delivered an exception of parameterized type T.
Uses Promise under the hood.| Constructor and Description |
|---|
Event(java.lang.String name,
ExceptionChainer<T> chainer,
LoggerFactory loggerFactory)
Creates this event with given
name and exception chainer. |
Event(java.lang.String name,
ExceptionChainer<T> chainer,
java.util.concurrent.locks.ReentrantLock lock,
LoggerFactory loggerFactory)
Creates this event with given
name, exception chainer, and associated lock. |
| Modifier and Type | Method and Description |
|---|---|
void |
await()
Await this event to have a definite
true or false value. |
void |
await(long timeout,
java.util.concurrent.TimeUnit unit)
Await this event to have a definite
true or false value, for timeout duration. |
void |
clear()
Clear this event.
|
void |
deliverError(java.lang.Throwable t)
Deliver the error
t (after chaining) to any present or future waiters. |
boolean |
hasWaiters() |
boolean |
inError() |
boolean |
isSet() |
void |
lock()
Acquire the lock associated with this event.
|
void |
set()
Sets this event to be
true. |
java.lang.String |
toString() |
boolean |
tryAwait(long timeout,
java.util.concurrent.TimeUnit unit)
Await this event to have a definite
true or false value, for timeout duration. |
void |
unlock()
Release the lock associated with this event.
|
public Event(java.lang.String name,
ExceptionChainer<T> chainer,
LoggerFactory loggerFactory)
name and exception chainer. Allocates a new Lock object for this event.name - name of this eventchainer - ExceptionChainer that will be used for chaining exceptionspublic Event(java.lang.String name,
ExceptionChainer<T> chainer,
java.util.concurrent.locks.ReentrantLock lock,
LoggerFactory loggerFactory)
name, exception chainer, and associated lock.name - name of this eventchainer - ExceptionChainer that will be used for chaining exceptionslock - lock to usepublic void set()
true. Short for set(true).public void clear()
!isSet().public void deliverError(java.lang.Throwable t)
t (after chaining) to any present or future waiters.public boolean isSet()
set() or deliverError(java.lang.Throwable)public void await()
throws T extends java.lang.Throwable
true or false value.T - if another thread meanwhile informs this event of an errorT extends java.lang.Throwablepublic void await(long timeout,
java.util.concurrent.TimeUnit unit)
throws T extends java.lang.Throwable
true or false value, for timeout duration.timeout - timeoutunit - the time unit for the timeoutT - if another thread meanwhile informs this event of an error, or timeout expiresT extends java.lang.Throwablepublic boolean tryAwait(long timeout,
java.util.concurrent.TimeUnit unit)
throws T extends java.lang.Throwable
true or false value, for timeout duration.
If the definite value is not available when the timeout expires, returns false.timeout - timeoutunit - the time unit for the timeoutT - if another thread meanwhile informs this event of an errorT extends java.lang.Throwablepublic boolean hasWaiters()
public boolean inError()
public void lock()
public void unlock()
public java.lang.String toString()
toString in class java.lang.Object