- java.lang.Object
-
- org.eclipse.jetty.util.thread.ThreadPoolBudget
-
public class ThreadPoolBudget extends java.lang.ObjectA budget of required thread usage, used to warn or error for insufficient configured threads.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceThreadPoolBudget.LeaseclassThreadPoolBudget.LeasedAn allocation of threads
-
Constructor Summary
Constructors Constructor Description ThreadPoolBudget(ThreadPool.SizedThreadPool pool)Construct a budget for a SizedThreadPool.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancheck(int maxThreads)Checks leases against the given number ofmaxThreads.ThreadPool.SizedThreadPoolgetSizedThreadPool()static ThreadPoolBudget.LeaseleaseFrom(java.util.concurrent.Executor executor, java.lang.Object leasee, int threads)ThreadPoolBudget.LeaseleaseTo(java.lang.Object leasee, int threads)voidreset()
-
-
-
Constructor Detail
-
ThreadPoolBudget
public ThreadPoolBudget(ThreadPool.SizedThreadPool pool)
Construct a budget for a SizedThreadPool.- Parameters:
pool- The pool to budget thread allocation for.
-
-
Method Detail
-
getSizedThreadPool
public ThreadPool.SizedThreadPool getSizedThreadPool()
-
reset
public void reset()
-
leaseTo
public ThreadPoolBudget.Lease leaseTo(java.lang.Object leasee, int threads)
-
check
public boolean check(int maxThreads) throws java.lang.IllegalStateExceptionChecks leases against the given number of
maxThreads.- Parameters:
maxThreads- A proposed change to the maximum threads to check.- Returns:
- true if passes check, false if otherwise (see logs for details)
- Throws:
java.lang.IllegalStateException- if insufficient threads are configured.
-
leaseFrom
public static ThreadPoolBudget.Lease leaseFrom(java.util.concurrent.Executor executor, java.lang.Object leasee, int threads)
-
-