Package io.netty.channel.pool
Class AbstractChannelPoolMap<K,P extends ChannelPool>
java.lang.Object
io.netty.channel.pool.AbstractChannelPoolMap<K,P>
- All Implemented Interfaces:
ChannelPoolMap<K,
,P> Closeable
,AutoCloseable
,Iterable<Map.Entry<K,
P>>
public abstract class AbstractChannelPoolMap<K,P extends ChannelPool>
extends Object
implements ChannelPoolMap<K,P>, Iterable<Map.Entry<K,P>>, Closeable
A skeletal
ChannelPoolMap
implementation. To find the right ChannelPool
the Object.hashCode()
and Object.equals(Object)
is used.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal void
close()
final boolean
final P
Return theChannelPool
for thecode
.final boolean
isEmpty()
iterator()
protected abstract P
Called once a newChannelPool
needs to be created as non exists yet for thekey
.If the pool implementation supports asynchronous close, then use it to avoid a blocking close call in case the ChannelPoolMap operations are called from an EventLoop.final boolean
Remove theChannelPool
from thisAbstractChannelPoolMap
.removeAsyncIfSupported
(K key) Remove theChannelPool
from thisAbstractChannelPoolMap
.final int
size()
Returns the number ofChannelPool
s currently in thisAbstractChannelPoolMap
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
map
-
-
Constructor Details
-
AbstractChannelPoolMap
public AbstractChannelPoolMap()
-
-
Method Details
-
get
Description copied from interface:ChannelPoolMap
Return theChannelPool
for thecode
. This will never returnnull
, but create a newChannelPool
if non exists for they requestedkey
. Please note thatnull
keys are not allowed.- Specified by:
get
in interfaceChannelPoolMap<K,
P extends ChannelPool>
-
remove
Remove theChannelPool
from thisAbstractChannelPoolMap
. Returnstrue
if removed,false
otherwise. If the removed pool extendsSimpleChannelPool
it will be closed asynchronously to avoid blocking in this method. Please note thatnull
keys are not allowed. -
removeAsyncIfSupported
Remove theChannelPool
from thisAbstractChannelPoolMap
. Returns a future that comletes with atrue
result if the pool has been removed by this call, otherwise the result isfalse
. If the removed pool extendsSimpleChannelPool
it will be closed asynchronously to avoid blocking in this method. The returned future will be completed once this asynchronous pool close operation completes. -
poolCloseAsyncIfSupported
If the pool implementation supports asynchronous close, then use it to avoid a blocking close call in case the ChannelPoolMap operations are called from an EventLoop.- Parameters:
pool
- the ChannelPool to be closed
-
iterator
-
size
public final int size()Returns the number ofChannelPool
s currently in thisAbstractChannelPoolMap
. -
isEmpty
public final boolean isEmpty() -
contains
Description copied from interface:ChannelPoolMap
- Specified by:
contains
in interfaceChannelPoolMap<K,
P extends ChannelPool>
-
newPool
Called once a newChannelPool
needs to be created as non exists yet for thekey
. -
close
public final void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-