unify sender/senderFuture into channel (++)
(squashed merge from the various bits and pieces already part of release-1.2, everything related to Channel & Future)
This commit is contained in:
parent
cee934a99a
commit
7712c20620
28 changed files with 679 additions and 252 deletions
|
|
@ -5,7 +5,7 @@ package akka.testkit
|
|||
|
||||
import akka.event.EventHandler
|
||||
import akka.actor.ActorRef
|
||||
import akka.dispatch.{ MessageDispatcher, MessageInvocation, FutureInvocation }
|
||||
import akka.dispatch.{ MessageDispatcher, MessageInvocation, FutureInvocation, Promise, ActorPromise }
|
||||
import java.util.concurrent.locks.ReentrantLock
|
||||
import java.util.LinkedList
|
||||
import java.util.concurrent.RejectedExecutionException
|
||||
|
|
@ -140,14 +140,14 @@ class CallingThreadDispatcher(val warnings: Boolean = true) extends MessageDispa
|
|||
val queue = mbox.queue
|
||||
val execute = mbox.suspended.ifElseYield {
|
||||
queue.push(handle)
|
||||
if (warnings && handle.senderFuture.isDefined) {
|
||||
if (warnings && handle.channel.isInstanceOf[Promise[_]]) {
|
||||
EventHandler.warning(this, "suspended, creating Future could deadlock; target: %s" format handle.receiver)
|
||||
}
|
||||
false
|
||||
} {
|
||||
queue.push(handle)
|
||||
if (queue.isActive) {
|
||||
if (warnings && handle.senderFuture.isDefined) {
|
||||
if (warnings && handle.channel.isInstanceOf[Promise[_]]) {
|
||||
EventHandler.warning(this, "blocked on this thread, creating Future could deadlock; target: %s" format handle.receiver)
|
||||
}
|
||||
false
|
||||
|
|
@ -186,14 +186,18 @@ class CallingThreadDispatcher(val warnings: Boolean = true) extends MessageDispa
|
|||
if (handle ne null) {
|
||||
try {
|
||||
handle.invoke
|
||||
val f = handle.senderFuture
|
||||
if (warnings && f.isDefined && !f.get.isCompleted) {
|
||||
EventHandler.warning(this, "calling %s with message %s did not reply as expected, might deadlock" format (handle.receiver, handle.message))
|
||||
if (warnings) handle.channel match {
|
||||
case f: ActorPromise if !f.isCompleted ⇒
|
||||
EventHandler.warning(this, "calling %s with message %s did not reply as expected, might deadlock" format (handle.receiver, handle.message))
|
||||
case _ ⇒
|
||||
}
|
||||
true
|
||||
} catch {
|
||||
case _ ⇒ queue.leave
|
||||
case e ⇒
|
||||
EventHandler.error(this, e)
|
||||
queue.leave
|
||||
false
|
||||
}
|
||||
true
|
||||
} else if (queue.isActive) {
|
||||
queue.leave
|
||||
false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue