summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorPhilipp Haller <hallerp@gmail.com>2006-11-13 16:19:22 +0000
committerPhilipp Haller <hallerp@gmail.com>2006-11-13 16:19:22 +0000
commitb00a1198aa69dd112da9d2b36f28a74472066c90 (patch)
tree60cd19462b5bd2d2e3385b783d3a396b70778781 /docs
parent97f3e8050eebdc7da129c1dcf73665ce3ffbbfd5 (diff)
downloadscala-b00a1198aa69dd112da9d2b36f28a74472066c90.tar.gz
scala-b00a1198aa69dd112da9d2b36f28a74472066c90.tar.bz2
scala-b00a1198aa69dd112da9d2b36f28a74472066c90.zip
Removed old iterator example.
Diffstat (limited to 'docs')
-rw-r--r--docs/examples/actors/Joins.scala58
1 files changed, 0 insertions, 58 deletions
diff --git a/docs/examples/actors/Joins.scala b/docs/examples/actors/Joins.scala
deleted file mode 100644
index 85105ec178..0000000000
--- a/docs/examples/actors/Joins.scala
+++ /dev/null
@@ -1,58 +0,0 @@
-package examples.actors
-
-import scala.actors.Actor._
-
-abstract class Producer[T] extends Iterator[T] {
- protected def produce(x: T): unit = coordinator ! HasValue(x)
- protected def produceValues: unit
-
- def hasNext = { setCurrent(); !current.isEmpty }
-
- def next: T = {
- setCurrent()
- val res = current.get
- current = (coordinator !? Next).asInstanceOf[Option[T]]
- res
- }
-
- private var current: Option[T] = null
- private def setCurrent() =
- if (current == null) current = (coordinator !? Next).asInstanceOf[Option[T]]
-
- private case class HasValue(value: T)
- private case object Next
- private case object Done
- private case object Continue
-
- private val coordinator = actor {
- while (true)
- receive {
- case Next =>
- reply {
- receive {
- case HasValue(v) =>
- Some(v)
- case Done =>
- None
- }
- }
- }
- }
-
- actor {
- produceValues
- coordinator ! Done
- }
-}
-
-object Joins extends Application {
- def from(m: int, n: int) = new Producer[int] {
- def produceValues = for (val i <- m until n) produce(i)
- }
-
- // note that it works from the main thread
- val it = from(1, 10)
- while (it.hasNext) {
- Console.println(it.next)
- }
-}