summaryrefslogtreecommitdiff
path: root/src/actors
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2006-11-14 09:45:28 +0000
committermichelou <michelou@epfl.ch>2006-11-14 09:45:28 +0000
commit8e2cb2b07a2fa55055afd5d85143ccc2a7adbebf (patch)
treee66e99b473a552333f086729b9d239f20d41b6e4 /src/actors
parenta18c1441c6c9837f152c0d9c898e4d863837bbcb (diff)
downloadscala-8e2cb2b07a2fa55055afd5d85143ccc2a7adbebf.tar.gz
scala-8e2cb2b07a2fa55055afd5d85143ccc2a7adbebf.tar.bz2
scala-8e2cb2b07a2fa55055afd5d85143ccc2a7adbebf.zip
updated scaladoc comments in actors/*.scala
Diffstat (limited to 'src/actors')
-rw-r--r--src/actors/scala/actors/Reaction.scala12
-rw-r--r--src/actors/scala/actors/Scheduler.scala17
-rw-r--r--src/actors/scala/actors/TimerThread.scala46
3 files changed, 50 insertions, 25 deletions
diff --git a/src/actors/scala/actors/Reaction.scala b/src/actors/scala/actors/Reaction.scala
index 7fb4372a36..4ee0a6a11e 100644
--- a/src/actors/scala/actors/Reaction.scala
+++ b/src/actors/scala/actors/Reaction.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2005-2006, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2005-2007, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -11,11 +11,8 @@
package scala.actors
-import java.lang.Runnable
-import java.lang.InterruptedException
-
-import java.util.logging.Logger
-import java.util.logging.Level
+import java.lang.{InterruptedException, Runnable}
+import java.util.logging.{Level, Logger}
/**
* The abstract class <code>Reaction</code> associates an instance
@@ -30,6 +27,9 @@ import java.util.logging.Level
private[actors] abstract class Reaction extends Runnable {
def actor: Actor
+ /**
+ * @param t ...
+ */
def log(t: Throwable): unit = {
Debug.info("logging "+t)
val logger = Logger.getLogger("Scheduler")
diff --git a/src/actors/scala/actors/Scheduler.scala b/src/actors/scala/actors/Scheduler.scala
index e869e2a31e..ca1a3ddcf6 100644
--- a/src/actors/scala/actors/Scheduler.scala
+++ b/src/actors/scala/actors/Scheduler.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2005-2006, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2005-2007, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -183,6 +183,9 @@ class TickedScheduler extends Thread with IScheduler {
}
}
+ /**
+ * @param item the task to be executed.
+ */
def execute(item: Reaction): unit = synchronized {
if (!terminating)
if (idle.length > 0) {
@@ -194,6 +197,10 @@ class TickedScheduler extends Thread with IScheduler {
tasks += item
}
+ /**
+ * @param worker the worker thread executing tasks
+ * @return the executed task
+ */
def getTask(worker: WorkerThread) = synchronized {
if (terminating)
QUIT_TASK
@@ -210,6 +217,9 @@ class TickedScheduler extends Thread with IScheduler {
var ticksCnt = 0
+ /**
+ * @param a the actor
+ */
def tick(a: Actor): unit = synchronized {
ticksCnt = ticksCnt + 1
executing.get(a) match {
@@ -221,6 +231,8 @@ class TickedScheduler extends Thread with IScheduler {
}
}
+ /** Shuts down all idle worker threads.
+ */
def shutdown(): unit = synchronized {
terminating = true
@@ -236,6 +248,9 @@ class TickedScheduler extends Thread with IScheduler {
}
+/**
+ * The <code>QuickException</code> class ...
+ */
class QuitException extends Throwable {
/*
For efficiency reasons we do not fill in
diff --git a/src/actors/scala/actors/TimerThread.scala b/src/actors/scala/actors/TimerThread.scala
index 0bd51a2c1c..b28953ee7a 100644
--- a/src/actors/scala/actors/TimerThread.scala
+++ b/src/actors/scala/actors/TimerThread.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2005-2006, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2005-2007, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -11,12 +11,12 @@
package scala.actors
-
-import java.lang.{Runnable, Thread}
-import java.lang.InterruptedException
-
+import java.lang.{InterruptedException, Runnable, Thread}
+import java.util.Date
import java.util.logging.{Logger, Level}
+import scala.collection.mutable.PriorityQueue
+
/**
* This class allows the (local) sending of a message to an actor after
* a timeout. Used by the library to build <code>receiveWithin(time: long)</code>.
@@ -24,8 +24,7 @@ import java.util.logging.{Logger, Level}
* message is received before the time-out occurs.
*
* @version 0.9.0
- * @author Sebastien Noir
- * @author Philipp Haller
+ * @author Sebastien Noir, Philipp Haller
*/
object TimerThread extends AnyRef with Runnable {
@@ -36,11 +35,14 @@ object TimerThread extends AnyRef with Runnable {
def compare(that: WakedActor): int = -(this.time compare that.time)
}
- var queue = new scala.collection.mutable.PriorityQueue[WakedActor]
+ var queue = new PriorityQueue[WakedActor]
val t = new Thread(this); t.start
var lateList: List[WakedActor] = Nil
+ /**
+ * @param a ...
+ */
def trashRequest(a: Actor) = synchronized {
// keep in mind: killing dead people is a bad idea!
queue.elements.find((wa: WakedActor) => wa.actor == a && wa.valid) match {
@@ -55,6 +57,9 @@ object TimerThread extends AnyRef with Runnable {
}
}
+ /**
+ * @param t ...
+ */
def log(t: Throwable): unit = {
Debug.info("logging "+t)
val logger = Logger.getLogger("Scheduler")
@@ -73,10 +78,10 @@ object TimerThread extends AnyRef with Runnable {
while(true) {
this.synchronized {
try {
- val sleepTime = dequeueLateAndGetSleepTime
- if (lateList.isEmpty) wait(sleepTime)
+ val sleepTime = dequeueLateAndGetSleepTime
+ if (lateList.isEmpty) wait(sleepTime)
} catch {
- case t: Throwable => { log(t); throw t }
+ case t: Throwable => { log(t); throw t }
}
}
@@ -95,6 +100,11 @@ object TimerThread extends AnyRef with Runnable {
}
}
+ /**
+ * @param a ...
+ * @param f ...
+ * @param waitMillis ...
+ */
def requestTimeout(a: Actor, f: PartialFunction[Any, Unit], waitMillis: long): unit = synchronized {
val wakeTime = now + waitMillis
if (waitMillis <= 0) {
@@ -108,11 +118,11 @@ object TimerThread extends AnyRef with Runnable {
notify()
} else
if (queue.max.time > wakeTime) { // add to 1st position and restart sleeping
- queue += WakedActor (a, f, wakeTime)
- notify()
+ queue += WakedActor (a, f, wakeTime)
+ notify()
}
else // simply add to queue
- queue += WakedActor (a, f, wakeTime)
+ queue += WakedActor (a, f, wakeTime)
}
private def dequeueLateAndGetSleepTime: long = {
@@ -123,11 +133,11 @@ object TimerThread extends AnyRef with Runnable {
val next = queue.max.time
val amount = next - now
if (amount > 0) { // guy in queue is not late
- lateList = waitingList // give back the list of waiting guys for signaling
- return amount
+ lateList = waitingList // give back the list of waiting guys for signaling
+ return amount
}
else // we're late: dequeue and examine next guy
- waitingList = queue.dequeue :: waitingList
+ waitingList = queue.dequeue :: waitingList
}
// empty queue => sleep forever
@@ -135,5 +145,5 @@ object TimerThread extends AnyRef with Runnable {
return FOREVER
}
- def now = new java.util.Date().getTime()
+ def now = new Date().getTime()
}