fixed some major bugs + wrote thread pool builder and dispatcher config + various spawnLink variations on Actor

This commit is contained in:
Jonas Boner 2009-07-01 15:29:06 +02:00
parent 2cfeda0ce0
commit a4f1092659
28 changed files with 2168 additions and 617 deletions

View file

@ -19,15 +19,17 @@ object IdFactory {
val message: AnyRef,
val method: String,
val target: String,
val timeout: Long,
val tx: Option[Transaction],
val isOneWay: Boolean,
val isEscaped: Boolean) {
val isEscaped: Boolean,
val supervisorUuid: Option[String]) {
private[RemoteRequest] var _id = IdFactory.nextId
def id = _id
override def toString: String = synchronized {
"RemoteRequest[isActor: " + isActor + " | message: " + message + " | method: " + method +
" | target: " + target + " | tx: " + tx + " | isOneWay: " + isOneWay + "]"
"RemoteRequest[isActor: " + isActor + " | message: " + message + " | timeout: " + timeout + " | method: " + method +
" | target: " + target + " | tx: " + tx + " | isOneWay: " + isOneWay + " | supervisorUuid: " + supervisorUuid + "]"
}
override def hashCode(): Int = synchronized {
@ -36,6 +38,11 @@ object IdFactory {
result = HashCode.hash(result, message)
result = HashCode.hash(result, method)
result = HashCode.hash(result, target)
result = HashCode.hash(result, timeout)
result = HashCode.hash(result, isOneWay)
result = HashCode.hash(result, isEscaped)
result = if (tx.isDefined) HashCode.hash(result, tx.get) else result
result = if (supervisorUuid.isDefined) HashCode.hash(result, supervisorUuid.get) else result
result
}
@ -45,15 +52,22 @@ object IdFactory {
that.asInstanceOf[RemoteRequest].isActor == isActor &&
that.asInstanceOf[RemoteRequest].message == message &&
that.asInstanceOf[RemoteRequest].method == method &&
that.asInstanceOf[RemoteRequest].target == target
that.asInstanceOf[RemoteRequest].target == target &&
that.asInstanceOf[RemoteRequest].timeout == timeout &&
that.asInstanceOf[RemoteRequest].isOneWay == isOneWay &&
that.asInstanceOf[RemoteRequest].isEscaped == isEscaped &&
that.asInstanceOf[RemoteRequest].tx.isDefined == tx.isDefined &&
that.asInstanceOf[RemoteRequest].tx.get == tx.get &&
that.asInstanceOf[RemoteRequest].supervisorUuid.isDefined == supervisorUuid.isDefined &&
that.asInstanceOf[RemoteRequest].supervisorUuid.get == supervisorUuid.get
}
def newReplyWithMessage(message: AnyRef, tx: Option[Transaction]) = synchronized { new RemoteReply(true, id, message, null, tx) }
def newReplyWithMessage(message: AnyRef, tx: Option[Transaction]) = synchronized { new RemoteReply(true, id, message, null, tx, supervisorUuid) }
def newReplyWithException(error: Throwable) = synchronized { new RemoteReply(false, id, null, error, None) }
def newReplyWithException(error: Throwable) = synchronized { new RemoteReply(false, id, null, error, None, supervisorUuid) }
def cloneWithNewMessage(message: AnyRef, isEscaped: Boolean) = synchronized {
val request = new RemoteRequest(isActor, message, method, target, tx, isOneWay, isEscaped)
val request = new RemoteRequest(isActor, message, method, target, timeout, tx, isOneWay, isEscaped, supervisorUuid)
request._id = id
request
}
@ -63,10 +77,11 @@ object IdFactory {
val id: Long,
val message: AnyRef,
val exception: Throwable,
val tx: Option[Transaction]) {
val tx: Option[Transaction],
val supervisorUuid: Option[String]) {
override def toString: String = synchronized {
"RemoteReply[successful: " + successful + " | id: " + id + " | message: " +
message + " | exception: " + exception + " | tx: " + tx + "]"
"RemoteReply[successful: " + successful + " | id: " + id + " | message: " + message +
" | exception: " + exception + " | tx: " + tx + " | supervisorUuid: " + supervisorUuid + "]"
}
override def hashCode(): Int = synchronized {
@ -75,6 +90,8 @@ object IdFactory {
result = HashCode.hash(result, id)
result = HashCode.hash(result, message)
result = HashCode.hash(result, exception)
result = if (tx.isDefined) HashCode.hash(result, tx.get) else result
result = if (supervisorUuid.isDefined) HashCode.hash(result, supervisorUuid.get) else result
result
}
@ -84,6 +101,10 @@ object IdFactory {
that.asInstanceOf[RemoteReply].successful == successful &&
that.asInstanceOf[RemoteReply].id == id &&
that.asInstanceOf[RemoteReply].message == message &&
that.asInstanceOf[RemoteReply].exception == exception
that.asInstanceOf[RemoteReply].exception == exception &&
that.asInstanceOf[RemoteRequest].tx.isDefined == tx.isDefined &&
that.asInstanceOf[RemoteRequest].tx.get == tx.get &&
that.asInstanceOf[RemoteRequest].supervisorUuid.isDefined == supervisorUuid.isDefined &&
that.asInstanceOf[RemoteRequest].supervisorUuid.get == supervisorUuid.get
}
}