public class FirstInFirstOutReleaseRunner extends ReleaseRunner
ReleaseRunner
that uses a pool of FIFO scheduled
realtime threads to run handlers. This reduces the amount of threads
required for handling events compared with bounding a thread to each
handler. It also supports handlers that suspend themselves, e.g., by
calling the Object.wait()
method. The size of the pool of threads
is based on the number of handlers, the number of priorities in use, and
the number of cpus available. For systems with many
AsyncBaseEventHandler
instances, there can be significantly fewer
threads to run releases of those handlers in the system.Constructor and Description |
---|
FirstInFirstOutReleaseRunner(ConfigurationParameters config)
Same as
FirstInFirstOutReleaseRunner(ConfigurationParameters, RealtimeThreadGroup, IntBinaryOperator)
with arguments {(null, null, null)}. |
FirstInFirstOutReleaseRunner(ConfigurationParameters config,
RealtimeThreadGroup group,
IntBinaryOperator sizer)
Create a release runner which maintains a pool of threads to run releases
of
AsyncBaseEventHandler instances. |
Modifier and Type | Method and Description |
---|---|
protected void |
attach(Schedulable handler)
Attach a handler from this runner, so it will be released.
|
protected void |
detach(Schedulable handler)
Detach a handler from this runner, so it will no longer be released.
|
ConfigurationParameters |
getConfigurationParameters()
Get the
ConfigurationParameters object used for all threads
provided by this release runner. |
protected void |
release(Schedulable handler)
Finds a thread and has it call the
Runnable.run()
method. |
getRealtimeThreadGroup
public FirstInFirstOutReleaseRunner(ConfigurationParameters config, RealtimeThreadGroup group, IntBinaryOperator sizer)
AsyncBaseEventHandler
instances. The threads in the pool all
run in a given RealtimeThreadGroup
instance. The thread pool size
is determined by the binary function sizer
. When sizer
is null
, a reasonable default is provided.config
- the ConfigurationParameters object to use for all handler
run from this pool, which means for each thread in the pool.group
- The realtime thread group for the pool threads.sizer
- A binary function from the number of handlers and the
number of priorities of those handles to the
number of threads in the pool. It may use global
information, such as the number of available CPUs. It may
also ignore its arguments. The calculation should be
simple, since this is called often.public FirstInFirstOutReleaseRunner(ConfigurationParameters config)
FirstInFirstOutReleaseRunner(ConfigurationParameters, RealtimeThreadGroup, IntBinaryOperator)
with arguments {(null, null, null)}.public ConfigurationParameters getConfigurationParameters()
ReleaseRunner
ConfigurationParameters
object used for all threads
provided by this release runner.getConfigurationParameters
in class ReleaseRunner
protected final void release(Schedulable handler)
ReleaseRunner
Runnable.run()
method. Care should be exercised when implementing this method, since
it adds to both the latency and jitter of releasing events.
This method should only be called from the infrastructure.
release
in class ReleaseRunner
handler
- The handler to be released.protected void attach(Schedulable handler) throws StaticIllegalStateException
attach
in class ReleaseRunner
StaticIllegalStateException
- when handler
is
already attached.handler
- to be removed.protected void detach(Schedulable handler) throws StaticIllegalStateException
detach
in class ReleaseRunner
StaticIllegalStateException
- when handler
is not attached.handler
- to be detached.aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2022 aicas GmbH. All Rights Reserved.