Minor cleanups and fixing super.unregister
This commit is contained in:
parent
1e3b7ebefe
commit
eef1670b6b
4 changed files with 14 additions and 8 deletions
|
|
@ -433,10 +433,6 @@ trait Actor extends TransactionManagement with Logging {
|
|||
def start: Actor = synchronized {
|
||||
if (_isShutDown) throw new IllegalStateException("Can't restart an actor that has been shut down with 'exit'")
|
||||
if (!_isRunning) {
|
||||
if (messageDispatcher.isShutdown &&
|
||||
messageDispatcher.isInstanceOf[Dispatchers.globalExecutorBasedEventDrivenDispatcher.type]) {
|
||||
messageDispatcher.asInstanceOf[ExecutorBasedEventDrivenDispatcher].init
|
||||
}
|
||||
messageDispatcher.register(this)
|
||||
messageDispatcher.start
|
||||
_isRunning = true
|
||||
|
|
@ -459,7 +455,6 @@ trait Actor extends TransactionManagement with Logging {
|
|||
def stop = synchronized {
|
||||
if (_isRunning) {
|
||||
messageDispatcher.unregister(this)
|
||||
if (messageDispatcher.canBeShutDown) messageDispatcher.shutdown // shut down in the dispatcher's references is zero
|
||||
_isRunning = false
|
||||
_isShutDown = true
|
||||
shutdown
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ abstract class AbstractReactorBasedEventDrivenDispatcher(val name: String) exten
|
|||
|
||||
override def unregister(actor: Actor) = synchronized {
|
||||
messageInvokers.remove(actor)
|
||||
super.register(actor)
|
||||
super.unregister(actor)
|
||||
}
|
||||
|
||||
def shutdown = if (active) {
|
||||
|
|
|
|||
|
|
@ -39,7 +39,14 @@ import se.scalablesolutions.akka.actor.Actor
|
|||
* @author <a href="http://jonasboner.com">Jonas Bonér</a>
|
||||
*/
|
||||
object Dispatchers {
|
||||
object globalExecutorBasedEventDrivenDispatcher extends ExecutorBasedEventDrivenDispatcher("global")
|
||||
object globalExecutorBasedEventDrivenDispatcher extends ExecutorBasedEventDrivenDispatcher("global") {
|
||||
override def register(actor : Actor) = {
|
||||
if (isShutdown)
|
||||
init
|
||||
super.register(actor)
|
||||
}
|
||||
}
|
||||
|
||||
object globalReactorBasedSingleThreadEventDrivenDispatcher extends ReactorBasedSingleThreadEventDrivenDispatcher("global")
|
||||
object globalReactorBasedThreadPoolEventDrivenDispatcher extends ReactorBasedThreadPoolEventDrivenDispatcher("global")
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,11 @@ trait MessageDispatcher extends Logging {
|
|||
def start
|
||||
def shutdown
|
||||
def register(actor: Actor) = references.put(actor.uuid, actor)
|
||||
def unregister(actor: Actor) = references.remove(actor.uuid)
|
||||
def unregister(actor: Actor) = {
|
||||
references.remove(actor.uuid)
|
||||
if (canBeShutDown)
|
||||
shutdown // shut down in the dispatcher's references is zero
|
||||
}
|
||||
def canBeShutDown: Boolean = references.isEmpty
|
||||
def isShutdown: Boolean
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue