public class BlockableReleaseRunner extends ReleaseRunner
ReleaseRunner
that can manage handlers that suspend
themselves, e.g., by calling the Object.wait()
method. It
maintains a pool of threads to run releases. It guarantees that at least
min(no. handlers, no. available CPUs + fraction of no. handlers)
are available for running releases, where the default fraction is defined
by the constant DEFAULT_LOADING_FACTOR
.
For systems with many AsyncBaseEventHandler
instances, there can
be significantly fewer threads to run releases of those handlers in
the system.Modifier and Type | Field and Description |
---|---|
static float |
DEFAULT_LOADING_FACTOR
The value of
loading used by the argumentless constructor. |
Constructor and Description |
---|
BlockableReleaseRunner(ConfigurationParameters config)
Same as
BlockableReleaseRunner(ConfigurationParameters, RealtimeThreadGroup, float)
with arguments {(null, null, 0.3f)}. |
BlockableReleaseRunner(ConfigurationParameters config,
RealtimeThreadGroup group,
float loading)
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(AsyncBaseEventHandler handler)
Attach a handler from this runner, so it will be released.
|
protected void |
detach(AsyncBaseEventHandler 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(AsyncBaseEventHandler handler)
Finds a thread and has it call the
Runnable.run()
method. |
getRealtimeThreadGroup
public static final float DEFAULT_LOADING_FACTOR
loading
used by the argumentless constructor.public BlockableReleaseRunner(ConfigurationParameters config, RealtimeThreadGroup group, float loading)
AsyncBaseEventHandler
instances. The threads in the pool all
run in a given RealtimeThreadGroup
instance. The thread pool size
is determined by the number of CPUs available to group
, and the
loading
, such that at least min( no. attached handlers,
no. available CPUs + (loading * no. attached handlers)
are available for running releases.UnsupportedOperationException
- everytime, since this is not implemented yet.config
- the ConfigurationParameters object to use for all handler
run from this pool, which means for each thread in the pool.group
- for the pool threads.loading
- a factor between 0.0 and 1.0 for deciding the number of
threads in the pool.public BlockableReleaseRunner(ConfigurationParameters config)
BlockableReleaseRunner(ConfigurationParameters, RealtimeThreadGroup, float)
with arguments {(null, null, 0.3f)}.public ConfigurationParameters getConfigurationParameters()
ConfigurationParameters
object used for all threads
provided by this release runner.getConfigurationParameters
in class ReleaseRunner
UnsupportedOperationException
- everytime, since this is not implemented yet.protected final void release(AsyncBaseEventHandler handler)
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
UnsupportedOperationException
- everytime, since this is not implemented yet.handler
- The handler to be released.protected final void attach(AsyncBaseEventHandler handler) throws StaticIllegalStateException
attach
in class ReleaseRunner
UnsupportedOperationException
- everytime, since this is not implemented yet.StaticIllegalStateException
- when handler
is
already attached.handler
- to be removed.protected final void detach(AsyncBaseEventHandler handler) throws StaticIllegalStateException
detach
in class ReleaseRunner
UnsupportedOperationException
- everytime, since this is not implemented yet.StaticIllegalStateException
- when handler
is not attached.handler
- to be detached.