Fix for message dispatcher attach (and async init)

This commit is contained in:
Peter Vlugter 2011-09-19 15:25:19 +02:00
parent 10ce9d703c
commit 5a9b6b1816

View file

@ -72,19 +72,22 @@ abstract class MessageDispatcher extends Serializable {
/**
* Attaches the specified actor instance to this dispatcher
*/
final def attach(actor: ActorInstance) {
guard withGuard {
final def attach(actor: ActorInstance): Unit = {
val promise = new ActorPromise(Timeout.never)(this)
guard.lock.lock()
try {
register(actor)
val promise = new ActorPromise(Timeout.never)(this)
dispatchMessage(new MessageInvocation(actor, Init, promise))
promise
}.get
} finally {
guard.lock.unlock()
}
promise.get
}
/**
* Detaches the specified actor instance from this dispatcher
*/
final def detach(actor: ActorInstance) {
final def detach(actor: ActorInstance): Unit = {
guard withGuard {
unregister(actor)
}