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
,LifeCycle
,TryExecutor
@ManagedObject("A pool for reserved threads") @Deprecated(since="2021-05-27") public class ReservedThreadExecutor extends AbstractLifeCycle implements TryExecutor
Deprecated.The Eclipse Jetty and Apache Felix Http Jetty packages are no longer supported.An Executor using preallocated/reserved Threads from a wrapped Executor.Calls to
execute(Runnable)
on aReservedThreadExecutor
will either succeed with a Thread immediately being assigned the Runnable task, or fail if no Thread is available.Threads are reserved lazily, with a new reserved thread being allocated from a wrapped
Executor
when an execution fails. If thesetIdleTimeout(long, TimeUnit)
is set to non zero (default 1 minute), then the reserved thread pool will shrink by 1 thread whenever it has been idle for that period.
-
-
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.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 Constructor Description ReservedThreadExecutor(Executor executor, int capacity)
Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
doStart()
Deprecated.void
doStop()
Deprecated.void
execute(Runnable task)
Deprecated.int
getAvailable()
Deprecated.int
getCapacity()
Deprecated.Executor
getExecutor()
Deprecated.long
getIdleTimeoutMs()
Deprecated.int
getPending()
Deprecated.void
setIdleTimeout(long idleTime, TimeUnit idleTimeUnit)
Deprecated.Set the idle timeout for shrinking the reserved thread poolString
toString()
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 Detail
-
ReservedThreadExecutor
public ReservedThreadExecutor(Executor executor, int capacity)
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 Detail
-
getExecutor
public Executor getExecutor()
Deprecated.
-
getCapacity
@ManagedAttribute(value="max number of reserved threads", readonly=true) public int getCapacity()
Deprecated.- Returns:
- the maximum number of reserved threads
-
getAvailable
@ManagedAttribute(value="available reserved threads", readonly=true) public int getAvailable()
Deprecated.- Returns:
- the number of threads available to
tryExecute(Runnable)
-
getPending
@ManagedAttribute(value="pending reserved threads", readonly=true) public int getPending()
Deprecated.
-
getIdleTimeoutMs
@ManagedAttribute(value="idletimeout in MS", readonly=true) public long getIdleTimeoutMs()
Deprecated.
-
setIdleTimeout
public void setIdleTimeout(long idleTime, TimeUnit idleTimeUnit)
Deprecated.Set the idle timeout for shrinking the reserved thread pool- Parameters:
idleTime
- Time to wait before shrinking, or 0 for no timeout.idleTimeUnit
- Time units for idle timeout
-
execute
public void execute(Runnable task) throws RejectedExecutionException
Deprecated.- Specified by:
execute
in interfaceExecutor
- Specified by:
execute
in interfaceTryExecutor
- Throws:
RejectedExecutionException
-
tryExecute
public boolean tryExecute(Runnable task)
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.
-
toString
public String toString()
Deprecated.- Overrides:
toString
in classAbstractLifeCycle
-
-