我想知道调用 val delegate = RemoteActor.select() 时是否有任何确定性。我问这个,因为我注意到当我通过网络发送代表时程序没有终止。
是否有任何其他副作用,取决于委托?
当 RemoteActor.select 将为相同的参数返回相同的委托时,是否有任何规则?
下面是一些演示 RemoteActor.select 问题的示例代码:
package test
import scala.actors.Actor, Actor._
import scala.actors.remote._, RemoteActor._
object DelegateTest {
def main(args :Array[String]) {
val actor = new Actorlein("localhost", 63000, 'first)
actor ! 'eval
}
}
class Actorlein(val host: String, val port: Int, val symbol: Symbol) extends Actor {
val preProxy1 = select(node, symbol)
val preProxy2 = select(node, symbol)
val node = Node(host,port)
this.start
alive(port)
register(symbol, this)
val initProxy1 = select(node, symbol)
val initProxy2 = select(node, symbol)
override def act = {
val actProxy1 = select(node, symbol)
val actProxy2 = select(node, symbol)
react {
case 'eval => {
val reactProxy1 = select(node, symbol)
val reactProxy2 = select(node, symbol)
//all true
println("pProxy equal? "+(preProxy1 == preProxy2))
println("iProxy equal? "+(initProxy1 == initProxy2))
println("aProxy equal? "+(actProxy1 == actProxy2))
println("rProxy equal? "+(reactProxy1 == reactProxy2))
//all true()
println("i equal p? "+(initProxy1 == preProxy1)) //false
println("r equal p? "+(reactProxy1 == preProxy1))//false
println("a equal p? "+(actProxy1 == preProxy1)) //false
println("i equal a? "+(initProxy1 == actProxy1)) //false
println("r equal a? "+(reactProxy1 == actProxy1))//true
}
case any => println("Unkown Msg: "+any)
}
}
}