blob: b56d22f7449bacd385b847bf2513322dabb12c15 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
/*
* @author Stephane Micheloud
*/
import scala.actors.Actor._
import scala.actors.remote.RemoteActor._
object Server extends ServerConsole {
private def computation(f: Int => Int): Int = {
//some time-consuming task
f(2)
}
def main(args: Array[String]) {
actor {
classLoader = serverClassLoader
alive(args(0).toInt)
register('Server, self)
loopWhile(isRunning) {
react {
case f: (Int => Int) =>
val result = computation(f)
sender ! result
}
}
}
}
}
|