public final class HawtCustomDispatchSource<Event,MergedEvent> extends AbstractDispatchObject implements CustomDispatchSource<Event,MergedEvent>
| Modifier and Type | Field and Description |
|---|---|
private EventAggregator<Event,MergedEvent> |
aggregator |
(package private) java.util.concurrent.atomic.AtomicBoolean |
canceled |
private Task |
cancelHandler |
static boolean |
DEBUG |
private Task |
eventHandler |
protected java.util.concurrent.ConcurrentLinkedQueue<MergedEvent> |
externalQueue |
private java.lang.ThreadLocal<MergedEvent> |
firedEvent |
private boolean |
ordered |
private java.lang.ThreadLocal<MergedEvent> |
outboundEvent |
private MergedEvent |
pendingEvent |
protected java.util.concurrent.atomic.AtomicLong |
size |
targetQueuestartup, suspended| Constructor and Description |
|---|
HawtCustomDispatchSource(HawtDispatcher dispatcher,
EventAggregator<Event,MergedEvent> aggregator,
DispatchQueue queue) |
| Modifier and Type | Method and Description |
|---|---|
void |
cancel()
Asynchronously cancel the dispatch source, preventing any further invocation
of its event handler runnable.
|
protected void |
debug(java.lang.String str,
java.lang.Object... args) |
protected void |
debug(java.lang.Throwable thrown,
java.lang.String str,
java.lang.Object... args) |
private void |
fireEvent(MergedEvent event) |
MergedEvent |
getData()
Returns pending data for the dispatch source.
|
boolean |
isCanceled() |
void |
merge(Event event)
Merges data into a dispatch source and submits its event handler runnable to its
target queue.
|
protected void |
onResume() |
protected void |
onStartup() |
void |
run() |
void |
setCancelHandler(java.lang.Runnable handler)
Deprecated.
|
void |
setCancelHandler(Task cancelHandler)
Sets the cancellation handler task for the given dispatch source.
|
void |
setEventHandler(java.lang.Runnable handler)
Deprecated.
|
void |
setEventHandler(Task eventHandler)
Sets the event handler task of this dispatch source.
|
getTargetQueue, setTargetQueueisSuspended, onSuspend, resume, suspendclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetTargetQueue, setTargetQueueisSuspended, resume, suspendpublic static final boolean DEBUG
final java.util.concurrent.atomic.AtomicBoolean canceled
private Task cancelHandler
private Task eventHandler
private final java.lang.ThreadLocal<MergedEvent> outboundEvent
private final java.lang.ThreadLocal<MergedEvent> firedEvent
private final EventAggregator<Event,MergedEvent> aggregator
private MergedEvent pendingEvent
private final boolean ordered
protected final java.util.concurrent.ConcurrentLinkedQueue<MergedEvent> externalQueue
protected final java.util.concurrent.atomic.AtomicLong size
public HawtCustomDispatchSource(HawtDispatcher dispatcher, EventAggregator<Event,MergedEvent> aggregator, DispatchQueue queue)
public MergedEvent getData()
CustomDispatchSourceReturns pending data for the dispatch source. Calling this method consumes the event and a subsequent call will return null.
This function is intended to be called from within the event handler runnable. The result of calling this function outside of the event handler runnable is undefined.
getData in interface CustomDispatchSource<Event,MergedEvent>public void merge(Event event)
CustomDispatchSourceMerges data into a dispatch source and submits its event handler runnable to its target queue.
merge in interface CustomDispatchSource<Event,MergedEvent>event - The value to coalesce with the pending data using the EventAggregator
that was specified when this dispach source was created.public void run()
run in interface java.lang.Runnablerun in class BaseSuspendableprivate void fireEvent(MergedEvent event)
protected void onStartup()
onStartup in class BaseSuspendablepublic void cancel()
DispatchSourceAsynchronously cancel the dispatch source, preventing any further invocation of its event handler runnable.
Cancellation prevents any further invocation of the event handler runnable for the specified dispatch source, but does not interrupt an event handler runnable that is already in progress.
The cancellation handler is submitted to the source's target queue once the the source's event handler has finished, indicating it is now safe to close the source's handle.
cancel in interface DispatchSourceDispatchSource.setCancelHandler(Runnable)protected void onResume()
onResume in class BaseSuspendablepublic boolean isCanceled()
isCanceled in interface DispatchSourceDispatchSource.cancel()@Deprecated public void setCancelHandler(java.lang.Runnable handler)
DispatchSourceSets the cancellation handler runnable for the given dispatch source.
The cancellation handler (if specified) will be submitted to the source's
target queue in response to a call to DispatchSource.cancel() once the
system has released all references to the source's underlying handle and
the source's event handler runnable has returned.
setCancelHandler in interface DispatchSourcehandler - The cancellation handler runnable to submit to the source's target queue.@Deprecated public void setEventHandler(java.lang.Runnable handler)
DispatchSourceSets the event handler runnable of this dispatch source.
setEventHandler in interface DispatchSourcehandler - The event handler runnable to submit to the source's target queue.public void setCancelHandler(Task cancelHandler)
DispatchSourceSets the cancellation handler task for the given dispatch source.
The cancellation handler (if specified) will be submitted to the source's
target queue in response to a call to DispatchSource.cancel() once the
system has released all references to the source's underlying handle and
the source's event handler runnable has returned.
setCancelHandler in interface DispatchSourcecancelHandler - The cancellation handler runnable to submit to the source's target queue.public void setEventHandler(Task eventHandler)
DispatchSourceSets the event handler task of this dispatch source.
setEventHandler in interface DispatchSourceeventHandler - The event handler runnable to submit to the source's target queue.protected void debug(java.lang.String str,
java.lang.Object... args)
protected void debug(java.lang.Throwable thrown,
java.lang.String str,
java.lang.Object... args)