Top Description Inners Methods
org.eclipse.jetty.util

public Interface Pool<P>

Known Direct Implementers
org.eclipse.jetty.util.Pool.Wrapper, org.eclipse.jetty.util.ConcurrentPool
Annotations
@ManagedObject
Type Parameters
<P>
the type of the pooled objects
Imports
java.util.Collection, java.util.function.Function, java.util.stream.Stream, org.eclipse.jetty.util.annotation.ManagedAttribute, .ManagedObject

A pool of objects, with support for multiplexing and several optimized strategies plus an optional ThreadLocal cache of the last released entry.

A Pool should be terminated when it is no longer needed; once terminated, it cannot be used anymore.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
Pool.Entry<
the type of the pooled objects
E
>

A Pool entry that holds metadata and a pooled object.

public static interface
Pool.Factory<
the type of the pooled objects
F
>

A factory for Pool instances.

public static class
Pool.Wrapper<
the type of the pooled objects
W
>

A wrapper for Pool instances.

Method Summary

Modifier and TypeMethod and Description
public Pool.Entry<P>

Returns:

an entry from the pool or null if none is available.
acquire
()

Acquires an entry from the pool.

public default Pool.Entry<P>

Returns:

an entry from the pool or null if none is available.
acquire
(Function<Pool.Entry<P>, P>
a function to create the pooled value for a reserved entry.
creator
)

Acquires an entry from the pool, reserving and creating a new entry if necessary.

public default int

Returns:

the number of idle entries
getIdleCount
()

public default int

Returns:

the number of in-use entries
getInUseCount
()

public int

Returns:

the maximum number of entries in this Pool
getMaxSize
()

public default int

Returns:

the number of reserved entries
getReservedCount
()

public default int

Returns:

the number of terminated entries
getTerminatedCount
()

public boolean

Returns:

whether this Pool has been terminated
isTerminated
()

public Pool.Entry<P>

Returns:

a disabled entry that is contained in the pool, or null if the pool is terminated or if the pool cannot reserve an entry
reserve
()

Creates a new disabled slot into the pool.

public int

Returns:

the current number of entries in this Pool
size
()

public Stream<Pool.Entry<P>>

Returns:

a Stream over the entries
stream
()

public Collection<Pool.Entry<P>>

Returns:

a list of all entries
terminate
()

Terminates this Pool.

Method Detail

acquireback to summary
public Pool.Entry<P> acquire()

Acquires an entry from the pool.

Only enabled entries will be returned from this method and their Entry#enable(Object, boolean) method must not be called.

Returns:Pool.Entry<P>

an entry from the pool or null if none is available.

acquireback to summary
public default Pool.Entry<P> acquire(Function<Pool.Entry<P>, P> creator)

Acquires an entry from the pool, reserving and creating a new entry if necessary.

Parameters
creator:Function<Pool.Entry<P>, P>

a function to create the pooled value for a reserved entry.

Returns:Pool.Entry<P>

an entry from the pool or null if none is available.

getIdleCountback to summary
public default int getIdleCount()
Returns:int

the number of idle entries

Annotations
@ManagedAttribute:The number of idle entries
getInUseCountback to summary
public default int getInUseCount()
Returns:int

the number of in-use entries

Annotations
@ManagedAttribute:The number of in-use entries
getMaxSizeback to summary
public int getMaxSize()
Returns:int

the maximum number of entries in this Pool

Annotations
@ManagedAttribute:The maximum number of entries
getReservedCountback to summary
public default int getReservedCount()
Returns:int

the number of reserved entries

Annotations
@ManagedAttribute:The number of reserved entries
getTerminatedCountback to summary
public default int getTerminatedCount()
Returns:int

the number of terminated entries

Annotations
@ManagedAttribute:The number of terminated entries
isTerminatedback to summary
public boolean isTerminated()
Returns:boolean

whether this Pool has been terminated

See Also
terminate()
reserveback to summary
public Pool.Entry<P> reserve()

Creates a new disabled slot into the pool.

The returned entry must ultimately have the Entry#enable(Object, boolean) method called or be removed via Pool.Entry#remove().

Returns:Pool.Entry<P>

a disabled entry that is contained in the pool, or null if the pool is terminated or if the pool cannot reserve an entry

sizeback to summary
public int size()
Returns:int

the current number of entries in this Pool

Annotations
@ManagedAttribute:The number of entries
streamback to summary
public Stream<Pool.Entry<P>> stream()
Returns:Stream<Pool.Entry<P>>

a Stream over the entries

terminateback to summary
public Collection<Pool.Entry<P>> terminate()

Terminates this Pool.

All the entries are marked as terminated and cannot be acquired nor released, but only removed.

The returned list of all entries may be iterated to perform additional operations on the pooled objects.

The pool cannot be used anymore after it is terminated.

Returns:Collection<Pool.Entry<P>>

a list of all entries

org.eclipse.jetty.util back to summary

public Interface Pool.Entry<E>

Known Direct Implementers
org.eclipse.jetty.util.Pool.Entry.Wrapper, org.eclipse.jetty.util.ConcurrentPool.ConcurrentEntry
Type Parameters
<E>
the type of the pooled objects

A Pool entry that holds metadata and a pooled object.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
Pool.Entry.Wrapper<
the type of the pooled objects
W
>

A wrapper for Entry instances.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

whether this Entry was enabled
enable
(E
the pooled object for this Entry
pooled
,
boolean
whether this Entry should be atomically enabled and acquired
acquire
)

Enables this, previously reserved, Entry.

public E

Returns:

the pooled object
getPooled
()

public boolean

Returns:

whether this Entry is idle in the Pool
isIdle
()

public boolean

Returns:

whether this Entry is in use
isInUse
()

public boolean

Returns:

whether this Entry is reserved
isReserved
()

public boolean

Returns:

whether this Entry is terminated
isTerminated
()

public boolean

Returns:

whether this Entry was released
release
()

Releases this Entry to the Pool.

public boolean

Returns:

whether this Entry was removed
remove
()

Removes this Entry from the Pool.

Method Detail

enableback to summary
public boolean enable(E pooled, boolean acquire)

Enables this, previously reserved, Entry.

An entry returned from the reserve() method must be enabled with this method, once and only once, before it is usable by the pool.

The entry may be enabled and not acquired, in which case it is immediately available to be acquired, potentially by another thread; or it can be enabled and acquired atomically so that no other thread can acquire it, although the acquire may still fail if the pool has been terminated.

Parameters
pooled:E

the pooled object for this Entry

acquire:boolean

whether this Entry should be atomically enabled and acquired

Returns:boolean

whether this Entry was enabled

Exceptions
IllegalStateException:
if this Entry was already enabled
getPooledback to summary
public E getPooled()
Returns:E

the pooled object

isIdleback to summary
public boolean isIdle()
Returns:boolean

whether this Entry is idle in the Pool

isInUseback to summary
public boolean isInUse()
Returns:boolean

whether this Entry is in use

isReservedback to summary
public boolean isReserved()
Returns:boolean

whether this Entry is reserved

See Also
Pool#reserve()
isTerminatedback to summary
public boolean isTerminated()
Returns:boolean

whether this Entry is terminated

releaseback to summary
public boolean release()

Releases this Entry to the Pool.

Returns:boolean

whether this Entry was released

removeback to summary
public boolean remove()

Removes this Entry from the Pool.

Returns:boolean

whether this Entry was removed

org.eclipse.jetty.util back to summary

public Class Pool.Entry.Wrapper<W>

extends Object
implements Pool.Entry<W>
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.util.Pool.Entry
Known Direct Subclasses
org.eclipse.jetty.util.LockedPool.LockedEntry
Type Parameters
<W>
the type of the pooled objects

A wrapper for Entry instances.

Field Summary

Modifier and TypeField and Description
private final Pool.Entry<W>

Constructor Summary

AccessConstructor and Description
public
Wrapper(Pool.Entry<W> wrapped)

Method Summary

Modifier and TypeMethod and Description
public boolean
enable(W
the pooled object for this Entry
pooled
,
boolean
whether this Entry should be atomically enabled and acquired
acquire
)

Implements org.eclipse.jetty.util.Pool.Entry.enable.

Enables this, previously reserved, Entry.

public W
public Pool.Entry<W>
public boolean
public boolean
public boolean
public boolean
public boolean
release()

Implements org.eclipse.jetty.util.Pool.Entry.release.

Releases this Entry to the Pool.

public boolean
remove()

Implements org.eclipse.jetty.util.Pool.Entry.remove.

Removes this Entry from the Pool.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

wrappedback to summary
private final Pool.Entry<W> wrapped

Constructor Detail

Wrapperback to summary
public Wrapper(Pool.Entry<W> wrapped)

Method Detail

enableback to summary
public boolean enable(W pooled, boolean acquire)

Implements org.eclipse.jetty.util.Pool.Entry.enable.

Doc from org.eclipse.jetty.util.Pool.Entry.enable.

Enables this, previously reserved, Entry.

An entry returned from the reserve() method must be enabled with this method, once and only once, before it is usable by the pool.

The entry may be enabled and not acquired, in which case it is immediately available to be acquired, potentially by another thread; or it can be enabled and acquired atomically so that no other thread can acquire it, although the acquire may still fail if the pool has been terminated.

Parameters
pooled:W

the pooled object for this Entry

acquire:boolean

whether this Entry should be atomically enabled and acquired

Returns:boolean

whether this Entry was enabled

Annotations
@Override
getPooledback to summary
public W getPooled()

Implements org.eclipse.jetty.util.Pool.Entry.getPooled.

Returns:W

Doc from org.eclipse.jetty.util.Pool.Entry.getPooled.

the pooled object

Annotations
@Override
getWrappedback to summary
public Pool.Entry<W> getWrapped()
isIdleback to summary
public boolean isIdle()

Implements org.eclipse.jetty.util.Pool.Entry.isIdle.

Returns:boolean

Doc from org.eclipse.jetty.util.Pool.Entry.isIdle.

whether this Entry is idle in the Pool

Annotations
@Override
isInUseback to summary
public boolean isInUse()

Implements org.eclipse.jetty.util.Pool.Entry.isInUse.

Returns:boolean

Doc from org.eclipse.jetty.util.Pool.Entry.isInUse.

whether this Entry is in use

Annotations
@Override
isReservedback to summary
public boolean isReserved()

Implements org.eclipse.jetty.util.Pool.Entry.isReserved.

Returns:boolean

Doc from org.eclipse.jetty.util.Pool.Entry.isReserved.

whether this Entry is reserved

Annotations
@Override
isTerminatedback to summary
public boolean isTerminated()

Implements org.eclipse.jetty.util.Pool.Entry.isTerminated.

Returns:boolean

Doc from org.eclipse.jetty.util.Pool.Entry.isTerminated.

whether this Entry is terminated

Annotations
@Override
releaseback to summary
public boolean release()

Implements org.eclipse.jetty.util.Pool.Entry.release.

Doc from org.eclipse.jetty.util.Pool.Entry.release.

Releases this Entry to the Pool.

Returns:boolean

whether this Entry was released

Annotations
@Override
removeback to summary
public boolean remove()

Implements org.eclipse.jetty.util.Pool.Entry.remove.

Doc from org.eclipse.jetty.util.Pool.Entry.remove.

Removes this Entry from the Pool.

Returns:boolean

whether this Entry was removed

Annotations
@Override
org.eclipse.jetty.util back to summary

public Interface Pool.Factory<F>

Known Direct Subinterfaces
org.eclipse.jetty.util.LockedPool.Factory
Type Parameters
<F>
the type of the pooled objects

A factory for Pool instances.

Method Summary

Modifier and TypeMethod and Description
public Pool<F>

Returns:

a new Pool instance
newPool
()

public default Pool<F>

Returns:

a possibly wrapped pool
wrap
(Pool<F>
the pool to wrap
pool
)

Wraps, if necessary, the given pool.

Method Detail

newPoolback to summary
public Pool<F> newPool()
Returns:Pool<F>

a new Pool instance

wrapback to summary
public default Pool<F> wrap(Pool<F> pool)

Wraps, if necessary, the given pool.

Parameters
pool:Pool<F>

the pool to wrap

Returns:Pool<F>

a possibly wrapped pool

See Also
Pool.Wrapper
org.eclipse.jetty.util back to summary

public Class Pool.Wrapper<W>

extends Object
implements Pool<W>
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.util.Pool
Known Direct Subclasses
org.eclipse.jetty.util.LockedPool
Type Parameters
<W>
the type of the pooled objects

A wrapper for Pool instances.

Field Summary

Modifier and TypeField and Description
private final Pool<W>

Constructor Summary

AccessConstructor and Description
public
Wrapper(Pool<W> wrapped)

Method Summary

Modifier and TypeMethod and Description
public Pool.Entry<W>
acquire()

Implements org.eclipse.jetty.util.Pool.acquire.

Acquires an entry from the pool.

public Pool.Entry<W>
acquire(Function<Pool.Entry<W>, W>
a function to create the pooled value for a reserved entry.
creator
)

Overrides default org.eclipse.jetty.util.Pool.acquire.

Acquires an entry from the pool, reserving and creating a new entry if necessary.

public int
public int
public int
public int
public int
public Pool<W>
public boolean
public Pool.Entry<W>
reserve()

Implements org.eclipse.jetty.util.Pool.reserve.

Creates a new disabled slot into the pool.

public int
public Stream<Pool.Entry<W>>
public Collection<Pool.Entry<W>>
terminate()

Implements org.eclipse.jetty.util.Pool.terminate.

Terminates this Pool.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

wrappedback to summary
private final Pool<W> wrapped

Constructor Detail

Wrapperback to summary
public Wrapper(Pool<W> wrapped)

Method Detail

acquireback to summary
public Pool.Entry<W> acquire()

Implements org.eclipse.jetty.util.Pool.acquire.

Doc from org.eclipse.jetty.util.Pool.acquire.

Acquires an entry from the pool.

Only enabled entries will be returned from this method and their Entry#enable(Object, boolean) method must not be called.

Returns:Pool.Entry<W>

an entry from the pool or null if none is available.

Annotations
@Override
acquireback to summary
public Pool.Entry<W> acquire(Function<Pool.Entry<W>, W> creator)

Overrides default org.eclipse.jetty.util.Pool.acquire.

Doc from org.eclipse.jetty.util.Pool.acquire.

Acquires an entry from the pool, reserving and creating a new entry if necessary.

Parameters
creator:Function<Pool.Entry<W>, W>

a function to create the pooled value for a reserved entry.

Returns:Pool.Entry<W>

an entry from the pool or null if none is available.

Annotations
@Override
getIdleCountback to summary
public int getIdleCount()

Overrides default org.eclipse.jetty.util.Pool.getIdleCount.

Returns:int

Doc from org.eclipse.jetty.util.Pool.getIdleCount.

the number of idle entries

Annotations
@Override
getInUseCountback to summary
public int getInUseCount()

Overrides default org.eclipse.jetty.util.Pool.getInUseCount.

Returns:int

Doc from org.eclipse.jetty.util.Pool.getInUseCount.

the number of in-use entries

Annotations
@Override
getMaxSizeback to summary
public int getMaxSize()

Implements org.eclipse.jetty.util.Pool.getMaxSize.

Returns:int

Doc from org.eclipse.jetty.util.Pool.getMaxSize.

the maximum number of entries in this Pool

Annotations
@Override
getReservedCountback to summary
public int getReservedCount()

Overrides default org.eclipse.jetty.util.Pool.getReservedCount.

Returns:int

Doc from org.eclipse.jetty.util.Pool.getReservedCount.

the number of reserved entries

Annotations
@Override
getTerminatedCountback to summary
public int getTerminatedCount()

Overrides default org.eclipse.jetty.util.Pool.getTerminatedCount.

Returns:int

Doc from org.eclipse.jetty.util.Pool.getTerminatedCount.

the number of terminated entries

Annotations
@Override
getWrappedback to summary
public Pool<W> getWrapped()
isTerminatedback to summary
public boolean isTerminated()

Implements org.eclipse.jetty.util.Pool.isTerminated.

Returns:boolean

Doc from org.eclipse.jetty.util.Pool.isTerminated.

whether this Pool has been terminated

Annotations
@Override
reserveback to summary
public Pool.Entry<W> reserve()

Implements org.eclipse.jetty.util.Pool.reserve.

Doc from org.eclipse.jetty.util.Pool.reserve.

Creates a new disabled slot into the pool.

The returned entry must ultimately have the Entry#enable(Object, boolean) method called or be removed via Pool.Entry#remove().

Returns:Pool.Entry<W>

a disabled entry that is contained in the pool, or null if the pool is terminated or if the pool cannot reserve an entry

Annotations
@Override
sizeback to summary
public int size()

Implements org.eclipse.jetty.util.Pool.size.

Returns:int

Doc from org.eclipse.jetty.util.Pool.size.

the current number of entries in this Pool

Annotations
@Override
streamback to summary
public Stream<Pool.Entry<W>> stream()

Implements org.eclipse.jetty.util.Pool.stream.

Returns:Stream<Pool.Entry<W>>

Doc from org.eclipse.jetty.util.Pool.stream.

a Stream over the entries

Annotations
@Override
terminateback to summary
public Collection<Pool.Entry<W>> terminate()

Implements org.eclipse.jetty.util.Pool.terminate.

Doc from org.eclipse.jetty.util.Pool.terminate.

Terminates this Pool.

All the entries are marked as terminated and cannot be acquired nor released, but only removed.

The returned list of all entries may be iterated to perform additional operations on the pooled objects.

The pool cannot be used anymore after it is terminated.

Returns:Collection<Pool.Entry<W>>

a list of all entries

Annotations
@Override