diff options
author | Gilles Dubochet <gilles.dubochet@epfl.ch> | 2005-12-16 18:44:33 +0000 |
---|---|---|
committer | Gilles Dubochet <gilles.dubochet@epfl.ch> | 2005-12-16 18:44:33 +0000 |
commit | 53a3cc7b17f4cf97075b7e71720777fd84109696 (patch) | |
tree | 0cc784e0b47ea49cc151a136d19f20bfa8ee2197 /sources/examples/computeserver.scala | |
parent | df50e05006b43b007c2587549030d24b5c154398 (diff) | |
download | scala-53a3cc7b17f4cf97075b7e71720777fd84109696.tar.gz scala-53a3cc7b17f4cf97075b7e71720777fd84109696.tar.bz2 scala-53a3cc7b17f4cf97075b7e71720777fd84109696.zip |
Created proper 'docs' folder for new layout.
Diffstat (limited to 'sources/examples/computeserver.scala')
-rw-r--r-- | sources/examples/computeserver.scala | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/sources/examples/computeserver.scala b/sources/examples/computeserver.scala deleted file mode 100644 index acc4a0b93e..0000000000 --- a/sources/examples/computeserver.scala +++ /dev/null @@ -1,42 +0,0 @@ -package examples; - -import concurrent._, concurrent.ops._; - -class ComputeServer(n: Int) { - - private trait Job { - type t; - def task: t; - def ret(x: t): Unit; - } - - private val openJobs = new Channel[Job](); - - private def processor(i: Int): Unit = { - while (true) { - val job = openJobs.read; - Console.println("read a job"); - job.ret(job.task) - } - } - - def future[a](p: => a): () => a = { - val reply = new SyncVar[a](); - openJobs.write{ - new Job { - type t = a; - def task = p; - def ret(x: a) = reply.set(x); - } - } - () => reply.get - } - - spawn(replicate(0, n) { processor }) -} - -object computeserver with Application { - val server = new ComputeServer(1); - val f = server.future(42); - Console.println(f()) -} |