Adding support for giving a Scala function to Index for comparison, and fixed a compilation error in NEttyRemoteSupport

This commit is contained in:
Viktor Klang 2011-10-12 13:42:54 +02:00
parent dd9555fa4b
commit aa1c636a6b
2 changed files with 7 additions and 1 deletions

View file

@ -17,6 +17,11 @@ import java.util.{ Comparator, Set ⇒ JSet }
* @author Viktor Klang
*/
class Index[K, V](val mapSize: Int, val valueComparator: Comparator[V]) {
def this(mapSize: Int, cmp: (V, V) Int) = this(mapSize, new Comparator[V] {
def compare(a: V, b: V): Int = cmp(a, b)
})
private val container = new ConcurrentHashMap[K, JSet[V]](mapSize)
private val emptySet = new ConcurrentSkipListSet[V]

View file

@ -35,6 +35,7 @@ import java.net.InetSocketAddress
import java.util.concurrent._
import java.util.concurrent.atomic._
import akka.AkkaException
import java.util.Comparator
class RemoteClientMessageBufferException(message: String, cause: Throwable = null) extends AkkaException(message, cause) {
def this(msg: String) = this(msg, null);
@ -57,7 +58,7 @@ object RemoteEncoder {
trait NettyRemoteClientModule extends RemoteClientModule {
self: ListenerManagement
private val remoteClients = new HashMap[RemoteAddress, RemoteClient]
private val remoteActors = new Index[RemoteAddress, Uuid]
private val remoteActors = new Index[RemoteAddress, Uuid](1024, _ compareTo _)
private val lock = new ReadWriteGuard
protected[akka] def send[T](message: Any,