From 2a52c9f3ab7b05d4be2f3138a61f065c3e3ac3af Mon Sep 17 00:00:00 2001 From: michelou Date: Wed, 13 Jun 2007 12:28:07 +0000 Subject: incremented MinorVersion, deprecated All/AllRef... incremented MinorVersion, deprecated All/AllRef, remove many type aliases --- src/actors/scala/actors/Actor.scala | 28 ++++++------- src/actors/scala/actors/Channel.scala | 6 +-- src/actors/scala/actors/Debug.scala | 4 +- src/actors/scala/actors/FJTaskScheduler2.scala | 20 ++++----- src/actors/scala/actors/Future.scala | 14 +++---- src/actors/scala/actors/InputChannel.scala | 4 +- src/actors/scala/actors/MessageQueue.scala | 2 +- src/actors/scala/actors/Scheduler.scala | 58 +++++++++++++------------- src/actors/scala/actors/TickedScheduler.scala | 21 +++++----- src/actors/scala/actors/TimerThread.scala | 12 +++--- 10 files changed, 85 insertions(+), 84 deletions(-) (limited to 'src/actors') diff --git a/src/actors/scala/actors/Actor.scala b/src/actors/scala/actors/Actor.scala index e5db1c5966..2d5e97433f 100644 --- a/src/actors/scala/actors/Actor.scala +++ b/src/actors/scala/actors/Actor.scala @@ -50,7 +50,7 @@ object Actor { * This permits to re-use the current thread as an actor * even if its ActorProxy has died for some reason. */ - def resetProxy: unit = { + def resetProxy { val a = tl.get.asInstanceOf[Actor] if ((null ne a) && a.isInstanceOf[ActorProxy]) tl.set(new ActorProxy(currentThread)) @@ -91,7 +91,7 @@ object Actor { * @param f a partial function specifying patterns and actions * @return the result of processing the received message */ - def receive[a](f: PartialFunction[Any, a]): a = + def receive[A](f: PartialFunction[Any, A]): A = self.receive(f) /** @@ -133,7 +133,7 @@ object Actor { * @param f a partial function specifying patterns and actions * @return this function never returns */ - def reactWithin(msec: long)(f: PartialFunction[Any, Unit]): Nothing = + def reactWithin(msec: Long)(f: PartialFunction[Any, Unit]): Nothing = self.reactWithin(msec)(f) def eventloop(f: PartialFunction[Any, Unit]): Nothing = @@ -141,9 +141,9 @@ object Actor { private class RecursiveProxyHandler(a: Actor, f: PartialFunction[Any, Unit]) extends PartialFunction[Any, Unit] { - def isDefinedAt(m: Any): boolean = + def isDefinedAt(m: Any): Boolean = true // events are immediately removed from the mailbox - def apply(m: Any): Unit = { + def apply(m: Any) { if (f.isDefinedAt(m)) f(m) self.react(this) } @@ -237,7 +237,7 @@ object Actor { */ def exit(): Nothing = self.exit() - def continue: unit = self.kill() + def continue: Unit = self.kill() } /** @@ -271,7 +271,7 @@ trait Actor extends OutputChannel[Any] { private var received: Option[Any] = None private[actors] val waitingForNone = (m: Any) => false - private[actors] var waitingFor: Any => boolean = waitingForNone + private[actors] var waitingFor: Any => Boolean = waitingForNone private[actors] var isSuspended = false private val mailbox = new MessageQueue @@ -326,7 +326,7 @@ trait Actor extends OutputChannel[Any] { result } - def receiveWithin[R](msec: long)(f: PartialFunction[Any, R]): R = { + def receiveWithin[R](msec: Long)(f: PartialFunction[Any, R]): R = { assert(Actor.self == this, "receive from channel belonging to other actor") if (shouldExit) exit() // links this.synchronized { @@ -389,7 +389,7 @@ trait Actor extends OutputChannel[Any] { } } - def reactWithin(msec: long)(f: PartialFunction[Any, Unit]): Nothing = { + def reactWithin(msec: Long)(f: PartialFunction[Any, Unit]): Nothing = { assert(Actor.self == this, "react on channel belonging to other actor") if (shouldExit) exit() // links Scheduler.pendReaction @@ -424,7 +424,7 @@ trait Actor extends OutputChannel[Any] { /** * Sends msg to this actor (asynchronous). */ - def !(msg: Any): Unit = { + def !(msg: Any) { send(msg, Actor.self.getReplyChannel) } @@ -452,7 +452,7 @@ trait Actor extends OutputChannel[Any] { * Otherwise, returns Some(value) where * value is the reply value. */ - def !?(msec: long, msg: Any): Option[Any] = { + def !?(msec: Long, msg: Any): Option[Any] = { val replyChannel = Actor.self.freshReply() this ! msg replyChannel.receiveWithin(msec) { @@ -491,10 +491,10 @@ trait Actor extends OutputChannel[Any] { * f. This also allows to recover a more * precise type for the reply value. */ - def !![a](msg: Any, f: PartialFunction[Any, a]): Future[a] = { + def !![A](msg: Any, f: PartialFunction[Any, A]): Future[A] = { val ftch = new Channel[Any](Actor.self) send(msg, ftch) - new Future[a](ftch) { + new Future[A](ftch) { def apply() = if (isSet) value.get else ch.receive { @@ -576,7 +576,7 @@ trait Actor extends OutputChannel[Any] { if (shouldExit) exit() } - def suspendActorFor(msec: long) { + def suspendActorFor(msec: Long) { val ts = Platform.currentTime var waittime = msec var fromExc = false diff --git a/src/actors/scala/actors/Channel.scala b/src/actors/scala/actors/Channel.scala index 52386c9b70..a11545cd5d 100644 --- a/src/actors/scala/actors/Channel.scala +++ b/src/actors/scala/actors/Channel.scala @@ -88,7 +88,7 @@ class Channel[Msg] extends InputChannel[Msg] with OutputChannel[Msg] { * @param f a partial function with message patterns and actions * @return result of processing the received value */ - def receiveWithin[R](msec: long)(f: PartialFunction[Any, R]): R = { + def receiveWithin[R](msec: Long)(f: PartialFunction[Any, R]): R = { val C = this.asInstanceOf[Channel[Any]] receiver.receiveWithin(msec) { case C ! msg if (f.isDefinedAt(msg)) => f(msg) @@ -121,7 +121,7 @@ class Channel[Msg] extends InputChannel[Msg] with OutputChannel[Msg] { * @param msec the time span before timeout * @param f a partial function with message patterns and actions */ - def reactWithin(msec: long)(f: PartialFunction[Any, Unit]): Nothing = { + def reactWithin(msec: Long)(f: PartialFunction[Any, Unit]): Nothing = { val C = this.asInstanceOf[Channel[Any]] receiver.reactWithin(msec) { case C ! msg if (f.isDefinedAt(msg)) => f(msg) @@ -153,7 +153,7 @@ class Channel[Msg] extends InputChannel[Msg] with OutputChannel[Msg] { * @return None in case of timeout, otherwise * Some(x) where x is the reply */ - def !?(msec: long, msg: Msg): Option[Any] = { + def !?(msec: Long, msg: Msg): Option[Any] = { val replyChannel = Actor.self.freshReply() receiver ! scala.actors.!(this, msg) replyChannel.receiveWithin(msec) { diff --git a/src/actors/scala/actors/Debug.scala b/src/actors/scala/actors/Debug.scala index 89efe5db62..4b73019861 100644 --- a/src/actors/scala/actors/Debug.scala +++ b/src/actors/scala/actors/Debug.scala @@ -17,7 +17,7 @@ object Debug { private var lev = 2 def level = lev - def level_= (lev: int) = { this.lev = lev } + def level_= (lev: Int) = { this.lev = lev } def info(s: String) = if (lev > 2) System.out.println("Info: " + s) @@ -33,7 +33,7 @@ class Debug(tag: String) { private var lev = 2 def level = lev - def level_= (lev: int) = { this.lev = lev } + def level_= (lev: Int) = { this.lev = lev } def info(s: String) = if (lev > 2) System.out.println(tag + " (info): " + s) diff --git a/src/actors/scala/actors/FJTaskScheduler2.scala b/src/actors/scala/actors/FJTaskScheduler2.scala index d1dd6e1d56..22d3627333 100644 --- a/src/actors/scala/actors/FJTaskScheduler2.scala +++ b/src/actors/scala/actors/FJTaskScheduler2.scala @@ -44,19 +44,19 @@ class FJTaskScheduler2 extends Thread with IScheduler { private var pendingReactions = 0 - def pendReaction: unit = synchronized { - pendingReactions = pendingReactions + 1 + def pendReaction: Unit = synchronized { + pendingReactions += 1 } - def unPendReaction: unit = synchronized { - pendingReactions = pendingReactions - 1 + def unPendReaction: Unit = synchronized { + pendingReactions -= 1 } def getPendingCount = synchronized { pendingReactions } - def setPendingCount(cnt: int) = synchronized { + def setPendingCount(cnt: Int) = synchronized { pendingReactions = cnt } @@ -66,17 +66,17 @@ class FJTaskScheduler2 extends Thread with IScheduler { private val TICK_FREQ = 50 private val CHECK_FREQ = 100 - def onLockup(handler: () => unit) = + def onLockup(handler: () => Unit) = lockupHandler = handler - def onLockup(millis: int)(handler: () => unit) = { + def onLockup(millis: Int)(handler: () => Unit) = { //LOCKUP_CHECK_FREQ = millis / CHECK_FREQ lockupHandler = handler } - private var lockupHandler: () => unit = null + private var lockupHandler: () => Unit = null - override def run(): unit = { + override def run() { try { while (!terminating) { this.synchronized { @@ -153,7 +153,7 @@ class FJTaskScheduler2 extends Thread with IScheduler { /** Shuts down all idle worker threads. */ - def shutdown(): unit = synchronized { + def shutdown(): Unit = synchronized { terminating = true // terminate timer thread TimerThread.shutdown() diff --git a/src/actors/scala/actors/Future.scala b/src/actors/scala/actors/Future.scala index 9020c7e971..1247fa5972 100644 --- a/src/actors/scala/actors/Future.scala +++ b/src/actors/scala/actors/Future.scala @@ -26,7 +26,7 @@ package scala.actors */ abstract class Future[T](val ch: InputChannel[Any]) extends Function0[T] { protected var value: Option[T] = None - def isSet: boolean + def isSet: Boolean } /** @@ -47,7 +47,7 @@ object Futures { a !! (Eval, { case any => any.asInstanceOf[T] }) } - def alarm(t: long) = future { + def alarm(t: Long) = future { Actor.reactWithin(t) { case TIMEOUT => {} } @@ -70,27 +70,27 @@ object Futures { * Note that some of the futures might already have been awaited. *

*/ - def awaitAll(timeout: long, fts: Future[Any]*): List[Option[Any]] = { + def awaitAll(timeout: Long, fts: Future[Any]*): List[Option[Any]] = { var resultsMap: collection.mutable.Map[Int, Option[Any]] = new collection.mutable.HashMap[Int, Option[Any]] var cnt = 0 val mappedFts = fts.map(ft => Pair({cnt+=1; cnt-1}, ft)) - val unsetFts = mappedFts.filter((p: Pair[int, Future[Any]]) => { + val unsetFts = mappedFts.filter((p: Pair[Int, Future[Any]]) => { if (p._2.isSet) { resultsMap(p._1) = Some(p._2()); false } else { resultsMap(p._1) = None; true } }) - val partFuns = unsetFts.map((p: Pair[int, Future[Any]]) => { + val partFuns = unsetFts.map((p: Pair[Int, Future[Any]]) => { val FutCh = p._2.ch - val singleCase: PartialFunction[Any, Pair[int, Any]] = { + val singleCase: PartialFunction[Any, Pair[Int, Any]] = { case FutCh ! any => Pair(p._1, any) } singleCase }) - def awaitWith(partFuns: Seq[PartialFunction[Any, Pair[int, Any]]]) { + def awaitWith(partFuns: Seq[PartialFunction[Any, Pair[Int, Any]]]) { val reaction: PartialFunction[Any, unit] = new PartialFunction[Any, unit] { def isDefinedAt(msg: Any) = msg match { case TIMEOUT => true diff --git a/src/actors/scala/actors/InputChannel.scala b/src/actors/scala/actors/InputChannel.scala index ab1841cb83..938a7986e5 100644 --- a/src/actors/scala/actors/InputChannel.scala +++ b/src/actors/scala/actors/InputChannel.scala @@ -19,7 +19,7 @@ package scala.actors */ trait InputChannel[+Msg] { def receive[R](f: PartialFunction[Msg, R]): R - def receiveWithin[R](msec: long)(f: PartialFunction[Any, R]): R + def receiveWithin[R](msec: Long)(f: PartialFunction[Any, R]): R def react(f: PartialFunction[Msg, Unit]): Nothing - def reactWithin(msec: long)(f: PartialFunction[Any, Unit]): Nothing + def reactWithin(msec: Long)(f: PartialFunction[Any, Unit]): Nothing } diff --git a/src/actors/scala/actors/MessageQueue.scala b/src/actors/scala/actors/MessageQueue.scala index 618e6f864e..51644f4471 100644 --- a/src/actors/scala/actors/MessageQueue.scala +++ b/src/actors/scala/actors/MessageQueue.scala @@ -45,7 +45,7 @@ class MessageQueue { } } - def extractFirst(p: Any => boolean): MessageQueueElement = { + def extractFirst(p: Any => Boolean): MessageQueueElement = { if (null eq last) null else { // test first element diff --git a/src/actors/scala/actors/Scheduler.scala b/src/actors/scala/actors/Scheduler.scala index 0eb97545b4..f5f42b6477 100644 --- a/src/actors/scala/actors/Scheduler.scala +++ b/src/actors/scala/actors/Scheduler.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** ** / __/ __// _ | / / / _ | (c) 2005-2007, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -41,13 +41,13 @@ object Scheduler { var tasks: LinkedQueue = null var pendingCount = 0 - def snapshot(): unit = synchronized { + def snapshot(): Unit = synchronized { tasks = sched.snapshot() pendingCount = sched.asInstanceOf[FJTaskScheduler2].getPendingCount sched.shutdown() } - def restart(): unit = synchronized { + def restart(): Unit = synchronized { sched = { var s: IScheduler = new FJTaskScheduler2 s.asInstanceOf[FJTaskScheduler2].setPendingCount(pendingCount) @@ -76,13 +76,13 @@ object Scheduler { def tick(a: Actor) = sched.tick(a) def terminated(a: Actor) = sched.terminated(a) - def pendReaction: unit = sched.pendReaction - def unPendReaction: unit = sched.unPendReaction + def pendReaction: Unit = sched.pendReaction + def unPendReaction: Unit = sched.unPendReaction def shutdown() = sched.shutdown() - def onLockup(handler: () => unit) = sched.onLockup(handler) - def onLockup(millis: int)(handler: () => unit) = sched.onLockup(millis)(handler) + def onLockup(handler: () => Unit) = sched.onLockup(handler) + def onLockup(millis: int)(handler: () => Unit) = sched.onLockup(millis)(handler) def printActorDump = sched.printActorDump } @@ -95,27 +95,27 @@ object Scheduler { * @author Philipp Haller */ trait IScheduler { - def start(): unit + def start(): Unit - def start(task: Reaction): unit - def execute(task: Reaction): unit - def execute(task: FJTask): unit + def start(task: Reaction): Unit + def execute(task: Reaction): Unit + def execute(task: FJTask): Unit def getTask(worker: WorkerThread): Runnable - def tick(a: Actor): unit - def terminated(a: Actor): unit - def pendReaction: unit - def unPendReaction: unit + def tick(a: Actor): Unit + def terminated(a: Actor): Unit + def pendReaction: Unit + def unPendReaction: Unit def snapshot(): LinkedQueue - def shutdown(): unit + def shutdown(): Unit - def onLockup(handler: () => unit): unit - def onLockup(millis: int)(handler: () => unit): unit - def printActorDump: unit + def onLockup(handler: () => Unit): Unit + def onLockup(millis: int)(handler: () => Unit): Unit + def printActorDump: Unit val QUIT_TASK = new Reaction(null) { - override def run(): unit = {} + override def run(): Unit = {} override def toString() = "QUIT_TASK" } } @@ -147,17 +147,17 @@ class SingleThreadedScheduler extends IScheduler { } def getTask(worker: WorkerThread): Runnable = null - def tick(a: Actor): Unit = {} - def terminated(a: Actor): unit = {} - def pendReaction: unit = {} - def unPendReaction: unit = {} + def tick(a: Actor) {} + def terminated(a: Actor) {} + def pendReaction {} + def unPendReaction {} - def shutdown(): Unit = {} + def shutdown() {} def snapshot(): LinkedQueue = { null } - def onLockup(handler: () => unit): unit = {} - def onLockup(millis: int)(handler: () => unit): unit = {} - def printActorDump: unit = {} + def onLockup(handler: () => Unit) {} + def onLockup(millis: Int)(handler: () => Unit) {} + def printActorDump {} } @@ -237,7 +237,7 @@ class WorkerThread(sched: IScheduler) extends Thread { notify() } - override def run(): unit = + override def run(): Unit = try { while (running) { if (task ne null) { diff --git a/src/actors/scala/actors/TickedScheduler.scala b/src/actors/scala/actors/TickedScheduler.scala index 1cd756fbe4..737384c294 100644 --- a/src/actors/scala/actors/TickedScheduler.scala +++ b/src/actors/scala/actors/TickedScheduler.scala @@ -29,23 +29,23 @@ class TickedScheduler extends Thread with IScheduler { // Worker threads private val workers: Buffer[WorkerThread] = new ArrayBuffer[WorkerThread] private val idle = new Queue[WorkerThread] - private val ticks = new HashMap[WorkerThread, long] + private val ticks = new HashMap[WorkerThread, Long] private var terminating = false private var lastActivity = Platform.currentTime private var pendingReactions = 0 - def pendReaction: unit = synchronized { + def pendReaction: Unit = synchronized { pendingReactions += 1 } - def unPendReaction: unit = synchronized { + def unPendReaction: Unit = synchronized { pendingReactions -= 1 } def printActorDump {} - def start(task: Reaction): unit = synchronized { + def start(task: Reaction): Unit = synchronized { pendingReactions += 1 execute(task) } @@ -61,17 +61,18 @@ class TickedScheduler extends Thread with IScheduler { worker.start() } - def onLockup(handler: () => unit) = + def onLockup(handler: () => Unit) { lockupHandler = handler + } - def onLockup(millis: int)(handler: () => unit) = { + def onLockup(millis: Int)(handler: () => Unit) { //LOCKUP_CHECK_FREQ = millis / CHECK_FREQ lockupHandler = handler } - private var lockupHandler: () => unit = null + private var lockupHandler: () => Unit = null - override def run(): unit = { + override def run() { try { while (!terminating) { this.synchronized { @@ -123,7 +124,7 @@ class TickedScheduler extends Thread with IScheduler { /** * @param item the task to be executed. */ - def execute(item: Reaction): unit = synchronized { + def execute(item: Reaction): Unit = synchronized { if (!terminating) { if (idle.length > 0) { val wt = idle.dequeue @@ -164,7 +165,7 @@ class TickedScheduler extends Thread with IScheduler { /** Shuts down all idle worker threads. */ - def shutdown(): unit = synchronized { + def shutdown(): Unit = synchronized { terminating = true val idleThreads = idle.elements while (idleThreads.hasNext) { diff --git a/src/actors/scala/actors/TimerThread.scala b/src/actors/scala/actors/TimerThread.scala index 73bd9c6551..4252c40253 100644 --- a/src/actors/scala/actors/TimerThread.scala +++ b/src/actors/scala/actors/TimerThread.scala @@ -28,10 +28,10 @@ import scala.compat.Platform object TimerThread { - private case class WakedActor(actor: Actor, f: PartialFunction[Any, Unit], time: long) + private case class WakedActor(actor: Actor, f: PartialFunction[Any, Unit], time: Long) extends Ordered[WakedActor] { var valid = true - def compare(that: WakedActor): int = -(this.time compare that.time) + def compare(that: WakedActor): Int = -(this.time compare that.time) } private var queue = new PriorityQueue[WakedActor] @@ -84,7 +84,7 @@ object TimerThread { } def requestTimeout(a: Actor, f: PartialFunction[Any, Unit], - waitMillis: long): unit = timerThread.synchronized { + waitMillis: Long): Unit = timerThread.synchronized { val wakeTime = now + waitMillis if (waitMillis <= 0) { a ! TIMEOUT @@ -117,8 +117,8 @@ object TimerThread { } } - private def dequeueLateAndGetSleepTime: long = { - val FOREVER: long = 0 + private def dequeueLateAndGetSleepTime: Long = { + val FOREVER: Long = 0 var waitingList: List[WakedActor] = Nil while (!queue.isEmpty) { @@ -134,7 +134,7 @@ object TimerThread { // empty queue => sleep forever lateList = waitingList - return FOREVER + FOREVER } private def now = Platform.currentTime -- cgit v1.2.3