From a92142e493017527e1f72a7406a85a63e13f1e9c Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Tue, 21 Jul 2009 10:33:58 +0000 Subject: [PATCH] More advice on extending OMATPE --- .../execution/OrderedMemoryAwareThreadPoolExecutor.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/jboss/netty/handler/execution/OrderedMemoryAwareThreadPoolExecutor.java b/src/main/java/org/jboss/netty/handler/execution/OrderedMemoryAwareThreadPoolExecutor.java index 2c924658d0..df5d5cbd70 100644 --- a/src/main/java/org/jboss/netty/handler/execution/OrderedMemoryAwareThreadPoolExecutor.java +++ b/src/main/java/org/jboss/netty/handler/execution/OrderedMemoryAwareThreadPoolExecutor.java @@ -24,6 +24,7 @@ package org.jboss.netty.handler.execution; import java.util.LinkedList; import java.util.Set; +import java.util.WeakHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.Executor; import java.util.concurrent.ThreadFactory; @@ -104,7 +105,7 @@ import org.jboss.netty.util.internal.ConcurrentIdentityWeakKeyHashMap; * ends (e.g. all connections from the same IP were closed.) Also, please * keep in mind that the key can appear again after calling {@link #removeChildExecutor(Object)} * (e.g. a new connection could come in from the old IP.) If in doubt, prune - * the old unused keys from the child executor map periodically: + * the old unused or stall keys from the child executor map periodically: * *
  * RemoteAddressBasedOMATPE executor = ...;
@@ -120,6 +121,11 @@ import org.jboss.netty.util.internal.ConcurrentIdentityWeakKeyHashMap;
  *   }
  * 
* + * If the expected maximum number of keys is small and deterministic, you could + * use a weak key map such as ConcurrentWeakHashMap + * or synchronized {@link WeakHashMap} instead of managing the life cycle of the + * keys by yourself. + * * @author The Netty Project (netty-dev@lists.jboss.org) * @author Trustin Lee (tlee@redhat.com) * @author David M. Lloyd (david.lloyd@redhat.com)