P
- is the type of Object received.public class AsyncObjectEventHandler<P> extends AsyncBaseEventHandler
AsyncBaseEventHandler
that carries an
Object
value as payload.Constructor and Description |
---|
AsyncObjectEventHandler()
Creates an instance of
AsyncObjectEventHandler (AOEH) with default
values for all parameters. |
AsyncObjectEventHandler(java.util.function.Consumer<P> logic)
Calling this constructor is equivalent to calling
AsyncObjectEventHandler(SchedulingParameters,
ReleaseParameters,
MemoryParameters,
MemoryArea,
ReleaseRunner,
Consumer)
with arguments (null, null, null, null, null, null, logic) . |
AsyncObjectEventHandler(SchedulingParameters scheduling,
ReleaseParameters release)
Calling this constructor is equivalent to calling
AsyncObjectEventHandler(SchedulingParameters,
ReleaseParameters,
MemoryParameters,
MemoryArea,
ReleaseRunner,
Consumer)
with arguments (scheduling, release, null, null, null, null) |
AsyncObjectEventHandler(SchedulingParameters scheduling,
ReleaseParameters release,
java.util.function.Consumer<P> logic)
Calling this constructor is equivalent to calling
AsyncObjectEventHandler(SchedulingParameters,
ReleaseParameters,
MemoryParameters,
MemoryArea,
ReleaseRunner,
Consumer)
with arguments (scheduling, release, null, null, null, logic) . |
AsyncObjectEventHandler(SchedulingParameters scheduling,
ReleaseParameters release,
MemoryParameters memory,
MemoryArea area,
ReleaseRunner runner,
java.util.function.Consumer<P> logic)
Creates an asynchronous event handler that receives an
Object
payload with each fire. |
Modifier and Type | Method and Description |
---|---|
void |
handleAsyncEvent(P payload)
This method holds the logic which is to be executed when any
AsyncEvent with which this handler is associated is fired. |
P |
peekPending()
Determines the next value queued for handling.
|
void |
run()
Calls
handleAsyncEvent repeatedly until the fire count
reaches zero. |
addIfFeasible, addToFeasibility, finalize, getAndClearPendingFireCount, getAndDecrementPendingFireCount, getDispatcher, getMemoryArea, getMemoryParameters, getPendingFireCount, getProcessingGroupParameters, getReleaseParameters, getScheduler, getSchedulingParameters, isDaemon, removeFromFeasibility, setDaemon, setIfFeasible, setIfFeasible, setIfFeasible, setIfFeasible, setIfFeasible, setMemoryParameters, setMemoryParametersIfFeasible, setProcessingGroupParameters, setProcessingGroupParametersIfFeasible, setReleaseParameters, setReleaseParametersIfFeasible, setScheduler, setScheduler, setSchedulingParameters, setSchedulingParametersIfFeasible
public AsyncObjectEventHandler(SchedulingParameters scheduling, ReleaseParameters release, MemoryParameters memory, MemoryArea area, ReleaseRunner runner, java.util.function.Consumer<P> logic) throws StaticIllegalArgumentException
Object
payload with each fire.scheduling
- Parameter for scheduling the new handler
(and possibly other instances of Schedulable
). When
scheduling
is null
and the
creator is an instance of Schedulable
,
SchedulingParameters
is a clone of the creator's value
created in the same memory area as this
. When
scheduling
is null
and the creator is
a task that is not an instance of Schedulable
, the
contents and type of the new SchedulingParameters
object are governed by the associated scheduler.release
- Parameter for scheduling the new handler
(and possibly other instances of Schedulable
). When
release
is null
the new
AsyncEventHandler
will use a clone of the
default ReleaseParameters
for the associated
scheduler created in the memory area that contains the
AsyncEventHandler
object.memory
- Parameter for scheduling the new handler
(and possibly other instances of Schedulable
). When
memory
is null
, the new
AsyncEventHandler
receives null
value
for its memory parameters, and the amount or rate of memory
allocation for the new handler is unrestricted.area
- The initial memory area of this handler.runner
- Logic to be executed by handleAsyncEvent(P)
logic
- The logic to run for each fire. When logic
is null
, the handleAsyncEvent
method in the new object will serve as its logic.StaticIllegalArgumentException
- when the event queue
overflow policy is QueueOverflowPolicy.DISABLE
.public AsyncObjectEventHandler(SchedulingParameters scheduling, ReleaseParameters release, java.util.function.Consumer<P> logic) throws StaticIllegalArgumentException
AsyncObjectEventHandler(SchedulingParameters,
ReleaseParameters,
MemoryParameters,
MemoryArea,
ReleaseRunner,
Consumer)
with arguments (scheduling, release, null, null, null, logic)
.StaticIllegalArgumentException
public AsyncObjectEventHandler(SchedulingParameters scheduling, ReleaseParameters release) throws StaticIllegalArgumentException
AsyncObjectEventHandler(SchedulingParameters,
ReleaseParameters,
MemoryParameters,
MemoryArea,
ReleaseRunner,
Consumer)
with arguments (scheduling, release, null, null, null, null)
StaticIllegalArgumentException
public AsyncObjectEventHandler(java.util.function.Consumer<P> logic)
AsyncObjectEventHandler(SchedulingParameters,
ReleaseParameters,
MemoryParameters,
MemoryArea,
ReleaseRunner,
Consumer)
with arguments (null, null, null, null, null, null, logic)
.public AsyncObjectEventHandler()
AsyncObjectEventHandler
(AOEH) with default
values for all parameters.public void handleAsyncEvent(P payload)
AsyncEvent
with which this handler is associated is fired.
This method will be invoked repeatedly while fireCount
is
greater than zero.
The default implementation of this method invokes the
run
method of any non-null logic
instance
passed to the constructor of this handler.
This AOEH is a source of reference for its initial memory area while this AOEH is released.
All throwables from (or propagated through)
handleAsyncEvent(P)
are caught, a stack trace is printed
and execution continues as if handleAsyncEvent(P)
had
returned normally.
payload
- The data associated with the release being handled.public P peekPending() throws StaticIllegalStateException
handleAsyncEvent(P)
}.StaticIllegalStateException
- when the fire count is zero.public final void run()
AsyncBaseEventHandler
handleAsyncEvent
repeatedly until the fire count
reaches zero. The method is only to be used by the infrastructure,
and should not be called by the application. The handleAsyncEvent
method should be overridden instead.
The handleAsyncEvent()
family of methods provides the
equivalent functionality to Runnable.run()
for asynchronous
event handlers, including execution of the logic
argument
passed to this object's constructor. Applications should override
that method or provide a logic
object for the default
implementation to invoke.
run
in interface java.lang.Runnable
run
in class AsyncBaseEventHandler
aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2019 aicas GmbH. All Rights Reserved.