diff options
Diffstat (limited to 'src/actors')
-rw-r--r-- | src/actors/scala/actors/Actor.scala | 156 | ||||
-rw-r--r-- | src/actors/scala/actors/Channel.scala | 48 | ||||
-rw-r--r-- | src/actors/scala/actors/Reactor.scala | 86 | ||||
-rw-r--r-- | src/actors/scala/actors/Scheduler.scala | 66 | ||||
-rw-r--r-- | src/actors/scala/actors/ThreadedActor.scala | 10 | ||||
-rw-r--r-- | src/actors/scala/actors/TimerThread.scala | 14 | ||||
-rw-r--r-- | src/actors/scala/actors/remote/FreshNameCreator.scala | 10 | ||||
-rw-r--r-- | src/actors/scala/actors/remote/JavaSerializer.scala | 14 | ||||
-rw-r--r-- | src/actors/scala/actors/remote/NetKernel.scala | 23 | ||||
-rw-r--r-- | src/actors/scala/actors/remote/Serializer.scala | 12 | ||||
-rw-r--r-- | src/actors/scala/actors/remote/Service.scala | 10 | ||||
-rw-r--r-- | src/actors/scala/actors/remote/TcpService.scala | 17 |
12 files changed, 293 insertions, 173 deletions
diff --git a/src/actors/scala/actors/Actor.scala b/src/actors/scala/actors/Actor.scala index 873835d177..e0e60dadd7 100644 --- a/src/actors/scala/actors/Actor.scala +++ b/src/actors/scala/actors/Actor.scala @@ -1,23 +1,33 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2005-2006, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: $ + package scala.actors import scala.collection.mutable.HashSet /** - This object provides functions for the definition of actors and - reactors, as well as all actor operations, such as - <code>receive</code>, <code>react</code>, <code>reply</code>, - etc. - - @author Philipp Haller + * This object provides functions for the definition of actors and + * reactors, as well as all actor operations, such as + * <code>receive</code>, <code>react</code>, <code>reply</code>, + * etc. + * + * @author Philipp Haller */ object Actor { private[actors] val selfs = new java.util.WeakHashMap(16, 0.5f) /** - Returns the currently executing actor. Should be used instead - of <code>this</code> in all blocks of code executed by - actors. + * Returns the currently executing actor. Should be used instead + * of <code>this</code> in all blocks of code executed by + * actors. */ def self: Actor = synchronized { val t = Thread.currentThread() @@ -34,8 +44,8 @@ object Actor { } /** - Creates an instance of a thread-based actor executing <code>body</code>, - and starts it. + * Creates an instance of a thread-based actor executing <code>body</code>, + * and starts it. */ def actor(body: => Unit): ActorThread = synchronized { val actor = new ActorThread { @@ -46,9 +56,9 @@ object Actor { } /** - Creates an instance of a thread-based actor specifying a - channel which can be used for typed communication with other - actors. + * Creates an instance of a thread-based actor specifying a + * channel which can be used for typed communication with other + * actors. */ def actor[a](ch: Channel[a])(body: => Unit): ActorThread = synchronized { val actor = new ActorThread { @@ -60,8 +70,8 @@ object Actor { } /** - Creates an instance of an event-based reactor executing - <code>body</code>, and starts it. + * Creates an instance of an event-based reactor executing + * <code>body</code>, and starts it. */ def reactor(body: => Unit): Reactor = synchronized { val reactor = new Reactor { @@ -72,12 +82,12 @@ object Actor { } /** - Receives a message from the mailbox of - <code>self</code>. Blocks if no message matching any of the - cases of <code>f</code> can be received. - - Only (thread-based) actors may call this method. It fails at - runtime if executed by a reactor. + * Receives a message from the mailbox of + * <code>self</code>. Blocks if no message matching any of the + * cases of <code>f</code> can be received. + * + * Only (thread-based) actors may call this method. It fails at + * runtime if executed by a reactor. */ def receive[a](f: PartialFunction[Any, a]): a = self.in.receive(f) @@ -244,10 +254,10 @@ object Actor { } /** - This trait defines commonalities between thread-based and - event-based actors. - - @author Philipp Haller + * This trait defines commonalities between thread-based and + * event-based actors. + * + * @author Philipp Haller */ trait Actor { @@ -269,21 +279,21 @@ trait Actor { } /** - The behavior of an actor is specified by implementing this - abstract method. Note that the preferred way to create actors - is through the <code>actor</code> and <code>reactor</code> - methods defined in object <code>Actor</code>. + * The behavior of an actor is specified by implementing this + * abstract method. Note that the preferred way to create actors + * is through the <code>actor</code> and <code>reactor</code> + * methods defined in object <code>Actor</code>. */ def act(): Unit /** - Sends <code>msg</code> to this actor (asynchronous). + * Sends <code>msg</code> to this actor (asynchronous). */ def !(msg: Any): Unit = in ! msg /** - Sends <code>msg</code> to this actor and awaits reply - (synchronous). + * Sends <code>msg</code> to this actor and awaits reply + * (synchronous). */ def !?(msg: Any): Any = in !? msg @@ -397,25 +407,25 @@ trait Actor { } /** - Messages of this type are sent to each actor <code>a</code> - that is linked to an actor <code>b</code> whenever - <code>b</code> terminates and <code>a</code> has - <code>trapExit</code> set to <code>true</code>. - - @author Philipp Haller + * Messages of this type are sent to each actor <code>a</code> + * that is linked to an actor <code>b</code> whenever + * <code>b</code> terminates and <code>a</code> has + * <code>trapExit</code> set to <code>true</code>. + * + * @author Philipp Haller */ case class Exit(from: Actor, reason: String) /** - This class provides an implementation for actors based on - threads. To be able to create instances of this class, the - inherited abstract method <code>act()</code> has to be - implemented. Note that the preferred way of creating - thread-based actors is through the <code>actor</code> method - defined in object <code>Actor</code>. - - @author Philipp Haller + * This class provides an implementation for actors based on + * threads. To be able to create instances of this class, the + * inherited abstract method <code>act()</code> has to be + * implemented. Note that the preferred way of creating + * thread-based actors is through the <code>actor</code> method + * defined in object <code>Actor</code>. + * + * @author Philipp Haller */ abstract class ActorThread extends Thread with ThreadedActor { override def run(): Unit = { @@ -456,10 +466,10 @@ abstract class ActorThread extends Thread with ThreadedActor { } /** - This class provides a dynamic actor proxy for normal Java - threads. - - @author Philipp Haller + * This class provides a dynamic actor proxy for normal Java + * threads. + * + * @author Philipp Haller */ private[actors] class ActorProxy(t: Thread) extends ThreadedActor { def act(): Unit = {} @@ -502,7 +512,7 @@ private[actors] class ActorProxy(t: Thread) extends ThreadedActor { <pre> actor { // ... - val c = select(TcpNode("127.0.0.1", 9010), 'myName) + <b>val</b> c = select(TcpNode("127.0.0.1", 9010), 'myName) c ! msg // ... } @@ -517,8 +527,8 @@ object RemoteActor { private val kernels = new scala.collection.mutable.HashMap[Actor, NetKernel] /** - Makes <code>self</code> remotely accessible on TCP port - <code>port</code>. + * Makes <code>self</code> remotely accessible on TCP port + * <code>port</code>. */ def alive(port: int): Unit = { val serv = new TcpService(port) @@ -527,8 +537,8 @@ object RemoteActor { } /** - Registers <code>a</code> under <code>name</code> on this - node. + * Registers <code>a</code> under <code>name</code> on this + * node. */ def register(name: Symbol, a: Actor): Unit = { val kernel = kernels.get(Actor.self) match { @@ -544,8 +554,8 @@ object RemoteActor { } /** - Returns (a proxy for) the actor registered under - <code>name</code> on <code>node</code>. + * Returns (a proxy for) the actor registered under + * <code>name</code> on <code>node</code>. */ def select(node: Node, name: Symbol): Actor = new Reactor { @@ -575,16 +585,24 @@ object RemoteActor { /** - This class represents a machine node on a TCP network. - - @author Philipp Haller + * This class represents a machine node on a TCP network. + * + * @author Philipp Haller */ case class Node(address: String, port: Int) /** - This class is used by our efficient message queue - implementation. + * <p> + * This class is used by our efficient message queue + * implementation. + * </p> + * <dl class="subclasses"> + * <dt><b>Direct Known Subclasses:</b></dt> + * <dd> + * <a href="MessageQueue.html" target="contentFrame">MessageQueue</a> + * </dd> + * </dl> */ private[actors] abstract class MessageQueueResult[Msg] { def msg: Msg @@ -592,12 +610,12 @@ private[actors] abstract class MessageQueueResult[Msg] { } /** - The class <code>MessageQueue</code> provides an efficient - implementation of a message queue specialized for this actor - library. Classes in this package are supposed to be the only - clients of this class. - - @author Martin Odersky, Philipp Haller + * The class <code>MessageQueue</code> provides an efficient + * implementation of a message queue specialized for this actor + * library. Classes in this package are supposed to be the only + * clients of this class. + * + * @author Martin Odersky, Philipp Haller */ private[actors] class MessageQueue[Msg] extends MessageQueueResult[Msg] { var msg: Msg = _ diff --git a/src/actors/scala/actors/Channel.scala b/src/actors/scala/actors/Channel.scala index a7e723f724..0121b97acd 100644 --- a/src/actors/scala/actors/Channel.scala +++ b/src/actors/scala/actors/Channel.scala @@ -1,3 +1,13 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2005-2006, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: $ + package scala.actors import Actor._ @@ -6,8 +16,8 @@ case object TIMEOUT class SuspendActorException extends Throwable { /* - For efficiency reasons we do not fill in - the execution stack trace. + * For efficiency reasons we do not fill in + * the execution stack trace. */ override def fillInStackTrace(): Throwable = { this @@ -15,11 +25,11 @@ class SuspendActorException extends Throwable { } /** - This class provides a means for typed communication among - actors. Only the actor creating an instance of a - <code>Channel</code> may receive from it. - - @author Philipp Haller + * This class provides a means for typed communication among + * actors. Only the actor creating an instance of a + * <code>Channel</code> may receive from it. + * + * @author Philipp Haller */ class Channel[Msg] { @@ -65,13 +75,13 @@ class Channel[Msg] { } /** - Sends <code>msg</code> to this <code>Channel</code>. + * Sends <code>msg</code> to this <code>Channel</code>. */ def !(msg: Msg): unit = send(msg, self) /** - Sends <code>msg</code> to this <code>Channel</code> and - awaits reply. + * Sends <code>msg</code> to this <code>Channel</code> and + * awaits reply. */ def !?(msg: Msg): Any = { self.freshReply() @@ -82,13 +92,13 @@ class Channel[Msg] { } /** - Forwards <code>msg</code> to <code>this</code> keeping the - last sender as sender instead of <code>self</code>. + * Forwards <code>msg</code> to <code>this</code> keeping the + * last sender as sender instead of <code>self</code>. */ def forward(msg: Msg): unit = send(msg, receiver.sender) /** - Receives a message from this <code>Channel</code>. + * Receives a message from this <code>Channel</code>. */ def receive[R](f: PartialFunction[Msg, R]): R = { assert(self == receiver, "receive from channel belonging to other actor") @@ -137,10 +147,10 @@ class Channel[Msg] { } /** - Receives a message from this <code>Channel</code>. If no - message could be received before <code>msec</code> - milliseconds elapsed, the <code>TIMEOUT</code> action is - executed if specified. + * Receives a message from this <code>Channel</code>. If no + * message could be received before <code>msec</code> + * milliseconds elapsed, the <code>TIMEOUT</code> action is + * executed if specified. */ def receiveWithin[R](msec: long)(f: PartialFunction[Any, R]): R = { assert(self == receiver, "receive from channel belonging to other actor") @@ -172,7 +182,7 @@ class Channel[Msg] { } /** - <code>receive</code> for reactors. + * <code>receive</code> for reactors. */ def react(f: PartialFunction[Any, Unit]): Nothing = { assert(self == receiver, "react on channel belonging to other actor") @@ -193,7 +203,7 @@ class Channel[Msg] { } /** - <code>receiveWithin</code> for reactors. + * <code>receiveWithin</code> for reactors. */ def reactWithin(msec: long)(f: PartialFunction[Any, Unit]): Nothing = { assert(self == receiver, "react on channel belonging to other actor") diff --git a/src/actors/scala/actors/Reactor.scala b/src/actors/scala/actors/Reactor.scala index d8cb0d0bb5..153220987b 100644 --- a/src/actors/scala/actors/Reactor.scala +++ b/src/actors/scala/actors/Reactor.scala @@ -1,13 +1,23 @@ -package scala.actors +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2005-2006, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ -/** - This class provides (together with <code>Channel</code>) an - implementation of event-based actors (aka reactors). +// $Id: $ - The main ideas of our approach are explained in the paper<br> - <b>Event-Based Programming without Inversion of Control</b>, Philipp Haller, Martin Odersky <i>Proc. JMLC 2006</i> +package scala.actors - @author Philipp Haller +/** + * This class provides (together with <code>Channel</code>) an + * implementation of event-based actors (aka reactors). + * + * The main ideas of our approach are explained in the paper<br> + * <b>Event-Based Programming without Inversion of Control</b>, Philipp Haller, Martin Odersky <i>Proc. JMLC 2006</i> + * + * @author Philipp Haller */ trait Reactor extends Actor { private var lastSender: Actor = null @@ -20,7 +30,7 @@ trait Reactor extends Actor { private[actors] var continuation: PartialFunction[Any, Unit] = null private[actors] var timeoutPending = false - private[actors] def scheduleActor(f: PartialFunction[Any, Unit], msg: Any) = { + private[actors] def scheduleActor(f: PartialFunction[Any, Unit], msg: Any) = if (f == null && continuation == null) { // do nothing (timeout is handled instead) } @@ -30,7 +40,6 @@ trait Reactor extends Actor { msg) Scheduler.execute(task) } - } private[actors] def defaultDetachActor: PartialFunction[Any, Unit] => Unit = (f: PartialFunction[Any, Unit]) => { @@ -48,15 +57,14 @@ trait Reactor extends Actor { resetActor() /** - Starts this reactor. + * Starts this reactor. */ - def start(): Unit = { + def start(): Unit = Scheduler.execute(new StartTask(this)) - } /** - Terminates this reactor, thereby influencing linked actors - (see Actor.exit). + * Terminates this reactor, thereby influencing linked actors + * (see Actor.exit). */ def exit(reason: String): Unit = { exitReason = reason @@ -65,23 +73,23 @@ trait Reactor extends Actor { } /** - The abstract class <code>Reaction</code> associates an instance - of a <code>Reactor</code> with a - <code>java.lang.Runnable</code>. It is also the super class of - the different kinds of tasks used for the execution of - <code>Reactor</code>s. - - @author Philipp Haller + * The abstract class <code>Reaction</code> associates an instance + * of a <code>Reactor</code> with a + * <code>java.lang.Runnable</code>. It is also the super class of + * the different kinds of tasks used for the execution of + * <code>Reactor</code>s. + * + * @author Philipp Haller */ private[actors] abstract class Reaction extends Runnable { def actor: Reactor } /** - This class represents task items used to start the execution - of <code>Reactor</code>s. - - @author Philipp Haller + * This class represents task items used to start the execution + * of <code>Reactor</code>s. + * + * @author Philipp Haller */ private[actors] class StartTask(a: Reactor) extends Reaction { def actor = a @@ -100,15 +108,12 @@ private[actors] class StartTask(a: Reactor) extends Reaction { a.exit("normal") } catch { - case _: InterruptedException => { + case _: InterruptedException => a.exitLinked() - } - case d: SuspendActorException => { + case d: SuspendActorException => // do nothing (continuation is already saved) - } - case t: Throwable => { + case t: Throwable => a.exit(t.toString()) - } } finally { Actor.selfs.put(t, saved) @@ -117,11 +122,11 @@ private[actors] class StartTask(a: Reactor) extends Reaction { } /** - This class represents task items used to execute actions - specified in arguments of <code>react</code> and - <code>reactWithin</code>. - - @author Philipp Haller + * This class represents task items used to execute actions + * specified in arguments of <code>react</code> and + * <code>reactWithin</code>. + * + * @author Philipp Haller */ private[actors] class ActorTask(a: Reactor, f: PartialFunction[Any, Unit], @@ -142,13 +147,12 @@ private[actors] class ActorTask(a: Reactor, a.exit("normal") } catch { - case _: InterruptedException => a.exitLinked() - case d: SuspendActorException => { + case _: InterruptedException => + a.exitLinked() + case d: SuspendActorException => // do nothing (continuation is already saved) - } - case t: Throwable => { + case t: Throwable => a.exit(t.toString()) - } } finally { Actor.selfs.put(t, saved) diff --git a/src/actors/scala/actors/Scheduler.scala b/src/actors/scala/actors/Scheduler.scala index 429437a6c7..57e04fa7cb 100644 --- a/src/actors/scala/actors/Scheduler.scala +++ b/src/actors/scala/actors/Scheduler.scala @@ -1,13 +1,23 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2005-2006, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: $ + package scala.actors -import scala.collection.mutable.{Queue,Buffer,ArrayBuffer} +import scala.collection.mutable.{ArrayBuffer, Buffer, Queue} /** - The <code>Scheduler</code> object is used by - <code>Reactor</code> to execute tasks of an execution of a - reactor. - - @author Philipp Haller + * The <code>Scheduler</code> object is used by + * <code>Reactor</code> to execute tasks of an execution of a + * reactor. + * + * @author Philipp Haller */ object Scheduler { private var sched: IScheduler = @@ -22,18 +32,16 @@ object Scheduler { sched.execute(task) } - def tick(a: Reactor) = { - sched.tick(a) - } + def tick(a: Reactor) = sched.tick(a) def shutdown(): Unit = sched.shutdown() } /** - This abstract class provides a common interface for all - schedulers used to execute reactors. - - @author Philipp Haller + * This abstract class provides a common interface for all + * schedulers used to execute reactors. + * + * @author Philipp Haller */ abstract class IScheduler { def execute(task: Reaction): Unit @@ -50,10 +58,10 @@ abstract class IScheduler { } /** - This scheduler executes the tasks of a reactor on a single - thread (the current thread). - - @author Philipp Haller + * This scheduler executes the tasks of a reactor on a single + * thread (the current thread). + * + * @author Philipp Haller */ class SingleThreadedScheduler extends IScheduler { def execute(task: Reaction): Unit = { @@ -69,10 +77,10 @@ class SingleThreadedScheduler extends IScheduler { } /** - This scheduler creates additional threads whenever there is no - idle thread available. - - @author Philipp Haller + * This scheduler creates additional threads whenever there is no + * idle thread available. + * + * @author Philipp Haller */ class SpareWorkerScheduler extends IScheduler { private val tasks = new Queue[Reaction] @@ -82,7 +90,7 @@ class SpareWorkerScheduler extends IScheduler { private var maxWorkers = 2 def init() = { - for (val i <- List.range(0, 2)) { + for (val i <- 0 until 2) { val worker = new WorkerThread(this) workers += worker worker.start() @@ -121,7 +129,7 @@ class SpareWorkerScheduler extends IScheduler { def shutdown(): Unit = synchronized { terminating = true val numNonIdle = workers.length - idle.length - for (val i <- List.range(0, numNonIdle)) + for (val i <- 0 until numNonIdle) tasks += QUIT_TASK val idleThreads = idle.elements while (idleThreads.hasNext) { @@ -133,10 +141,10 @@ class SpareWorkerScheduler extends IScheduler { } /** - This class is used by schedulers to execute reactor tasks on - multiple threads. - - @author Philipp Haller + * This class is used by schedulers to execute reactor tasks on + * multiple threads. + * + * @author Philipp Haller */ class WorkerThread(sched: IScheduler) extends Thread { private var task: Runnable = null @@ -150,9 +158,7 @@ class WorkerThread(sched: IScheduler) extends Thread { override def run(): Unit = synchronized { try { while (running) { - if (task != null) { - task.run() - } + if (task != null) task.run() task = sched.getTask(this) if (task == sched.QUIT_TASK) { running = false diff --git a/src/actors/scala/actors/ThreadedActor.scala b/src/actors/scala/actors/ThreadedActor.scala index 2e3e8ecc2b..3a0f49c82a 100644 --- a/src/actors/scala/actors/ThreadedActor.scala +++ b/src/actors/scala/actors/ThreadedActor.scala @@ -1,3 +1,13 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2005-2006, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: $ + package scala.actors /** diff --git a/src/actors/scala/actors/TimerThread.scala b/src/actors/scala/actors/TimerThread.scala index 205789415e..33b24ca74b 100644 --- a/src/actors/scala/actors/TimerThread.scala +++ b/src/actors/scala/actors/TimerThread.scala @@ -1,9 +1,19 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2005-2006, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: $ + package scala.actors /** * This class allows the (local) sending of a message to an actor after - * a timeout. Used by the library to build receiveWithin(time: long). - * Note that the library deletes non-received TIMEOUT message if a + * a timeout. Used by the library to build <code>receiveWithin(time: long)</code>. + * Note that the library deletes non-received <code>TIMEOUT</code> message if a * message is received before the time-out occurs. * * @author Sebastien Noir diff --git a/src/actors/scala/actors/remote/FreshNameCreator.scala b/src/actors/scala/actors/remote/FreshNameCreator.scala index 2e30c69f1f..f832c23b7e 100644 --- a/src/actors/scala/actors/remote/FreshNameCreator.scala +++ b/src/actors/scala/actors/remote/FreshNameCreator.scala @@ -1,3 +1,13 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2005-2006, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: $ + package scala.actors.remote object FreshNameCreator { diff --git a/src/actors/scala/actors/remote/JavaSerializer.scala b/src/actors/scala/actors/remote/JavaSerializer.scala index 94dabc3b47..7dd6f09c25 100644 --- a/src/actors/scala/actors/remote/JavaSerializer.scala +++ b/src/actors/scala/actors/remote/JavaSerializer.scala @@ -1,8 +1,20 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2005-2006, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: $ + package scala.actors.remote -import java.io.{ByteArrayInputStream,ByteArrayOutputStream,ObjectInputStream,ObjectOutputStream} +import java.io.{ByteArrayInputStream, ByteArrayOutputStream, + ObjectInputStream, ObjectOutputStream} class JavaSerializer(serv: Service) extends Serializer(serv) { + def serialize(o: AnyRef): Array[Byte] = { val bos = new ByteArrayOutputStream() val out = new ObjectOutputStream(bos) diff --git a/src/actors/scala/actors/remote/NetKernel.scala b/src/actors/scala/actors/remote/NetKernel.scala index 19d6f81f6a..5209ae4069 100644 --- a/src/actors/scala/actors/remote/NetKernel.scala +++ b/src/actors/scala/actors/remote/NetKernel.scala @@ -1,8 +1,16 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2005-2006, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: $ + package scala.actors.remote -import java.io.{IOException,StringReader,StringWriter} -import java.net.UnknownHostException -import scala.collection.mutable.{HashMap,HashSet} +import scala.collection.mutable.{HashMap, HashSet} case class NamedSend(senderName: Symbol, receiver: Symbol, data: Array[Byte]) @@ -25,7 +33,8 @@ class NetKernel(service: Service) { register(freshName, Actor.self) freshName } - case Some(name) => name + case Some(name) => + name } namedSend(node, senderName, name, msg) } @@ -40,9 +49,8 @@ class NetKernel(service: Service) { def act() = { a ! msg } override def !(msg: Any): Unit = { msg match { - case refmsg: AnyRef => { + case refmsg: AnyRef => namedSend(senderNode, receiver, senderName, refmsg) - } } } override def !?(msg: Any): Any = @@ -50,7 +58,8 @@ class NetKernel(service: Service) { } senderProxy.start() } - case None => // message is lost + case None => + // message is lost } } } diff --git a/src/actors/scala/actors/remote/Serializer.scala b/src/actors/scala/actors/remote/Serializer.scala index f68fdce263..c4f5dc680e 100644 --- a/src/actors/scala/actors/remote/Serializer.scala +++ b/src/actors/scala/actors/remote/Serializer.scala @@ -1,6 +1,16 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2005-2006, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: $ + package scala.actors.remote -import java.io.{DataInputStream,DataOutputStream,EOFException,IOException} +import java.io.{DataInputStream, DataOutputStream, EOFException, IOException} abstract class Serializer(val service: Service) { def serialize(o: AnyRef): Array[byte] diff --git a/src/actors/scala/actors/remote/Service.scala b/src/actors/scala/actors/remote/Service.scala index a9ccb3240c..6b32cd1d84 100644 --- a/src/actors/scala/actors/remote/Service.scala +++ b/src/actors/scala/actors/remote/Service.scala @@ -1,3 +1,13 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2005-2006, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: $ + package scala.actors.remote trait Service { diff --git a/src/actors/scala/actors/remote/TcpService.scala b/src/actors/scala/actors/remote/TcpService.scala index 0237cc0e96..715749dd96 100644 --- a/src/actors/scala/actors/remote/TcpService.scala +++ b/src/actors/scala/actors/remote/TcpService.scala @@ -1,8 +1,19 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2005-2006, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: $ + package scala.actors.remote -import java.io.{DataInputStream,DataOutputStream,BufferedReader,PrintWriter, - IOException,InputStreamReader,OutputStreamWriter} -import java.net.{InetAddress,ServerSocket,Socket,UnknownHostException} +import java.io.{BufferedReader, DataInputStream, DataOutputStream, + IOException, InputStreamReader, OutputStreamWriter, + PrintWriter} +import java.net.{InetAddress, ServerSocket, Socket, UnknownHostException} object TcpService { val random = new java.util.Random(System.currentTimeMillis()) |