Package org.eclipse.jetty.util
Class Pool<T>
- java.lang.Object
-
- org.eclipse.jetty.util.Pool<T>
-
- Type Parameters:
T
-
- All Implemented Interfaces:
AutoCloseable
,Dumpable
@Deprecated(since="2021-05-27") public class Pool<T> extends Object implements AutoCloseable, Dumpable
Deprecated.The Eclipse Jetty and Apache Felix Http Jetty packages are no longer supported.A fast pool of objects, with optional support for multiplexing, max usage count and several optimized strategies plus an optionalThreadLocal
cache of the last release entry.When the method
close()
is called, allCloseable
s in the pool are also closed.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
Pool.Entry
Deprecated.static class
Pool.StrategyType
Deprecated.The type of the strategy to use for the pool.-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainer
-
-
Constructor Summary
Constructors Constructor Description Pool(Pool.StrategyType strategyType, int maxEntries)
Deprecated.Construct a Pool with a specified lookup strategy and noThreadLocal
cache.Pool(Pool.StrategyType strategyType, int maxEntries, boolean cache)
Deprecated.Construct a Pool with the specified thread-local cache size and an optionalThreadLocal
cache.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Pool.Entry
acquire()
Deprecated.Acquire an entry from the pool.Pool.Entry
acquire(Function<Pool.Entry,T> creator)
Deprecated.Utility method to acquire an entry from the pool, reserving and creating a new entry if necessary.Pool.Entry
acquireAt(int idx)
Deprecated.No longer supported.void
close()
Deprecated.void
dump(Appendable out, String indent)
Deprecated.Dump this object (and children) into an Appendable using the provided indent after any new lines.int
getClosedCount()
Deprecated.int
getIdleCount()
Deprecated.int
getInUseCount()
Deprecated.int
getMaxEntries()
Deprecated.int
getMaxMultiplex()
Deprecated.int
getMaxUsageCount()
Deprecated.Get the maximum number of times the entries of the pool can be acquired.int
getReservedCount()
Deprecated.boolean
isClosed()
Deprecated.boolean
release(Pool.Entry entry)
Deprecated.This method will return an acquired object to the pool.boolean
remove(Pool.Entry entry)
Deprecated.Remove a value from the pool.Pool.Entry
reserve()
Deprecated.Create a new disabled slot into the pool.Pool.Entry
reserve(int allotment)
Deprecated.Usereserve()
insteadvoid
setMaxMultiplex(int maxMultiplex)
Deprecated.void
setMaxUsageCount(int maxUsageCount)
Deprecated.Change the max usage count of the pool's entries.int
size()
Deprecated.String
toString()
Deprecated.Collection<Pool.Entry>
values()
Deprecated.
-
-
-
Constructor Detail
-
Pool
public Pool(Pool.StrategyType strategyType, int maxEntries)
Deprecated.Construct a Pool with a specified lookup strategy and noThreadLocal
cache.- Parameters:
strategyType
- The strategy to used for looking up entries.maxEntries
- the maximum amount of entries that the pool will accept.
-
Pool
public Pool(Pool.StrategyType strategyType, int maxEntries, boolean cache)
Deprecated.Construct a Pool with the specified thread-local cache size and an optionalThreadLocal
cache.- Parameters:
strategyType
- The strategy to used for looking up entries.maxEntries
- the maximum amount of entries that the pool will accept.cache
- True if aThreadLocal
cache should be used to try the most recently released entry.
-
-
Method Detail
-
getReservedCount
public int getReservedCount()
Deprecated.
-
getIdleCount
public int getIdleCount()
Deprecated.
-
getInUseCount
public int getInUseCount()
Deprecated.
-
getClosedCount
public int getClosedCount()
Deprecated.
-
getMaxEntries
public int getMaxEntries()
Deprecated.
-
getMaxMultiplex
public int getMaxMultiplex()
Deprecated.
-
setMaxMultiplex
public final void setMaxMultiplex(int maxMultiplex)
Deprecated.
-
getMaxUsageCount
public int getMaxUsageCount()
Deprecated.Get the maximum number of times the entries of the pool can be acquired.- Returns:
- the max usage count.
-
setMaxUsageCount
public final void setMaxUsageCount(int maxUsageCount)
Deprecated.Change the max usage count of the pool's entries. All existing idle entries over this new max usage are removed and closed.- Parameters:
maxUsageCount
- the max usage count.
-
reserve
@Deprecated public Pool.Entry reserve(int allotment)
Deprecated.Usereserve()
insteadCreate a new disabled slot into the pool. The returned entry must ultimately have thePool.Entry.enable(Object, boolean)
method called or be removed viaPool.Entry.remove()
orremove(Pool.Entry)
.- Parameters:
allotment
- the desired allotment, where each entry handles an allotment of maxMultiplex, or a negative number to always trigger the reservation of a new entry.- Returns:
- a disabled entry that is contained in the pool,
or null if the pool is closed or if the pool already contains
getMaxEntries()
entries, or the allotment has already been reserved
-
reserve
public Pool.Entry reserve()
Deprecated.Create a new disabled slot into the pool. The returned entry must ultimately have thePool.Entry.enable(Object, boolean)
method called or be removed viaPool.Entry.remove()
orremove(Pool.Entry)
.- Returns:
- a disabled entry that is contained in the pool,
or null if the pool is closed or if the pool already contains
getMaxEntries()
entries
-
acquireAt
@Deprecated public Pool.Entry acquireAt(int idx)
Deprecated.No longer supported. Instead use aPool.StrategyType
to configure the pool.Acquire the entry from the pool at the specified index. This method bypasses the thread-local mechanism.- Parameters:
idx
- the index of the entry to acquire.- Returns:
- the specified entry or null if there is none at the specified index or if it is not available.
-
acquire
public Pool.Entry acquire()
Deprecated.Acquire an entry from the pool. Only enabled entries will be returned from this method and their enable method must not be called.- Returns:
- an entry from the pool or null if none is available.
-
acquire
public Pool.Entry acquire(Function<Pool.Entry,T> creator)
Deprecated.Utility method to acquire an entry from the pool, reserving and creating a new entry if necessary.- Parameters:
creator
- a function to create the pooled value for a reserved entry.- Returns:
- an entry from the pool or null if none is available.
-
release
public boolean release(Pool.Entry entry)
Deprecated.This method will return an acquired object to the pool. Objects that are acquired from the pool but never released will result in a memory leak.- Parameters:
entry
- the value to return to the pool- Returns:
- true if the entry was released and could be acquired again,
false if the entry should be removed by calling
remove(Pool.Entry)
and the object contained by the entry should be disposed. - Throws:
NullPointerException
- if value is null
-
remove
public boolean remove(Pool.Entry entry)
Deprecated.Remove a value from the pool.- Parameters:
entry
- the value to remove- Returns:
- true if the entry was removed, false otherwise
-
isClosed
public boolean isClosed()
Deprecated.
-
close
public void close()
Deprecated.- Specified by:
close
in interfaceAutoCloseable
-
size
public int size()
Deprecated.
-
values
public Collection<Pool.Entry> values()
Deprecated.
-
dump
public void dump(Appendable out, String indent) throws IOException
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
-
-