Package org.eclipse.jetty.util.thread
Class ReservedThreadExecutor
java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.thread.ReservedThreadExecutor
- All Implemented Interfaces:
Executor
,Dumpable
,LifeCycle
,TryExecutor
@ManagedObject("A pool for reserved threads")
@Deprecated(since="2021-05-27")
public class ReservedThreadExecutor
extends AbstractLifeCycle
implements TryExecutor, Dumpable
Deprecated.
The Eclipse Jetty and Apache Felix Http Jetty packages are no longer supported.
A TryExecutor using pre-allocated/reserved threads from an external Executor.
Calls to tryExecute(Runnable)
on ReservedThreadExecutor will either
succeed with a reserved thread immediately being assigned the task, or fail if
no reserved thread is available.
Threads are reserved lazily, with new reserved threads being allocated from the external
Executor
passed to the constructor. Whenever 1 or more reserved threads have been
idle for more than getIdleTimeoutMs()
then one reserved thread will return to
the external Executor.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainer
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.thread.TryExecutor
TryExecutor.NoTryExecutor
-
Field Summary
Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING
Fields inherited from interface org.eclipse.jetty.util.thread.TryExecutor
NO_TRY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
doStart()
Deprecated.void
doStop()
Deprecated.void
dump
(Appendable out, String indent) Deprecated.Dump this object (and children) into an Appendable using the provided indent after any new lines.void
Deprecated.int
Deprecated.int
Deprecated.Deprecated.long
Deprecated.int
Deprecated.void
setIdleTimeout
(long idleTime, TimeUnit idleTimeUnit) Deprecated.Set the idle timeout for shrinking the reserved thread pooltoString()
Deprecated.boolean
tryExecute
(Runnable task) Deprecated.Executes the given task if and only if a reserved thread is available.Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, setStopTimeout, start, stop
-
Constructor Details
-
ReservedThreadExecutor
Deprecated.- Parameters:
executor
- The executor to use to obtain threadscapacity
- The number of threads to preallocate. If less than 0 then capacity is calculated based on a heuristic from the number of available processors and thread pool size.
-
-
Method Details
-
getExecutor
Deprecated. -
getCapacity
Deprecated.- Returns:
- the maximum number of reserved threads
-
getAvailable
Deprecated.- Returns:
- the number of threads available to
tryExecute(Runnable)
-
getPending
Deprecated. -
getIdleTimeoutMs
Deprecated. -
setIdleTimeout
Deprecated.Set the idle timeout for shrinking the reserved thread pool- Parameters:
idleTime
- Time to wait before shrinking, or 0 for default timeout.idleTimeUnit
- Time units for idle timeout
-
doStart
Deprecated.- Throws:
Exception
-
doStop
Deprecated.- Throws:
Exception
-
execute
Deprecated.- Specified by:
execute
in interfaceExecutor
- Specified by:
execute
in interfaceTryExecutor
- Throws:
RejectedExecutionException
-
tryExecute
Deprecated.Executes the given task if and only if a reserved thread is available.
- Specified by:
tryExecute
in interfaceTryExecutor
- Parameters:
task
- the task to run- Returns:
- true if and only if a reserved thread was available and has been assigned the task to run.
-
dump
Deprecated.Description copied from interface:Dumpable
Dump this object (and children) into an Appendable using the provided indent after any new lines. The indent should not be applied to the first object dumped.- Specified by:
dump
in interfaceDumpable
- Parameters:
out
- The appendable to dump toindent
- The indent to apply after any new lines.- Throws:
IOException
- if unable to write to Appendable
-
toString
Deprecated.- Overrides:
toString
in classAbstractLifeCycle
-