Как мне убить RemoteActor? - PullRequest
       2

Как мне убить RemoteActor?

4 голосов
/ 25 июля 2010

Не уверен, что я что-то упустил. При удалении актера основной метод не завершается.

Вот фрагмент, который демонстрирует проблему.

import scala.actors._
import scala.actors.remote._
object TestMe {
  def main(args : Array[String]) : Unit = {
      object jim extends DaemonActor {
          // comment out these two lines and the application will terminate
          RemoteActor.alive(12345)
          RemoteActor.register('jim,this)         
          def act {
              loop {
                  receive {
                      case 'quit =>
                       println("\nquiting")
                        exit('normal)
                      case any => 
                        println(any)
                  }
              }
          }
      }
      jim.start
      jim ! "hello"
      jim ! 'quit
  }
}

1 Ответ

4 голосов
/ 25 июля 2010

Поместите ваши вызовы .alive и .register в act (), и ваш код успешно завершится.

...