improve DirectByteBufferPool and some smaller fixes

* dispatch Closed events to the sender of the close command as well
 * DirectByteBufferPool changes:

     * hide behind BufferPool interface
     * only return buffers of the configured size
     * reduce work to be done while locked
     * use Array-based stack to store free buffers instead of linked lists
     * keep buffers by soft reference
This commit is contained in:
Johannes Rudolph 2013-01-21 14:45:19 +01:00
parent 2f54a5b4d2
commit 9c9508d76f
4 changed files with 123 additions and 89 deletions

View file

@ -14,7 +14,7 @@ import java.net._
import scala.collection.immutable
import scala.concurrent.duration._
import scala.util.control.NonFatal
import akka.actor.{ ActorRef, Terminated }
import akka.actor.{ PoisonPill, ActorRef, Terminated }
import akka.testkit.{ TestProbe, TestActorRef, AkkaSpec }
import akka.util.ByteString
import TestUtils._
@ -84,7 +84,7 @@ class TcpConnectionSpec extends AkkaSpec("akka.io.tcp.register-timeout = 500ms")
buffer.clear()
serverSideChannel.read(buffer) must be(0)
writer.send(connectionActor, unackedWrite)
writer.expectNoMsg()
writer.expectNoMsg(500.millis)
serverSideChannel.read(buffer) must be(10)
buffer.flip()
ByteString(buffer).take(10).decodeString("ASCII") must be("morestuff!")
@ -172,7 +172,7 @@ class TcpConnectionSpec extends AkkaSpec("akka.io.tcp.register-timeout = 500ms")
connectionHandler.send(connectionActor, Close)
connectionHandler.expectMsg(Closed)
connectionHandler.expectNoMsg()
connectionHandler.expectNoMsg(500.millis)
}
"abort the connection and reply with `Aborted` upong reception of an `Abort` command" in withEstablishedConnection() { setup
@ -293,8 +293,7 @@ class TcpConnectionSpec extends AkkaSpec("akka.io.tcp.register-timeout = 500ms")
"close the connection when user handler dies while connecting" in withUnacceptedConnection() { setup
import setup._
// simulate death of userHandler test probe
userHandler.send(connectionActor, akka.actor.Terminated(userHandler.ref)(false, false))
userHandler.ref ! PoisonPill
verifyActorTermination(connectionActor)
}