diff options
author | Philipp Haller <hallerp@gmail.com> | 2007-08-14 14:50:53 +0000 |
---|---|---|
committer | Philipp Haller <hallerp@gmail.com> | 2007-08-14 14:50:53 +0000 |
commit | 564bc566d396e163e28abe4dc2b5deb15badebfd (patch) | |
tree | c9318f0f283ca4152dd9c3bce793d535d2afaaa1 /src/actors | |
parent | 145c188d55fa2a9865c42d977b6e1e1825042e65 (diff) | |
download | scala-564bc566d396e163e28abe4dc2b5deb15badebfd.tar.gz scala-564bc566d396e163e28abe4dc2b5deb15badebfd.tar.bz2 scala-564bc566d396e163e28abe4dc2b5deb15badebfd.zip |
Integrated Itay Neeman's patch to allow port mu...
Integrated Itay Neeman's patch to allow port multiplexing for remote
actors.
Diffstat (limited to 'src/actors')
-rw-r--r-- | src/actors/scala/actors/Reaction.scala | 2 | ||||
-rw-r--r-- | src/actors/scala/actors/remote/RemoteActor.scala | 5 | ||||
-rw-r--r-- | src/actors/scala/actors/remote/TcpService.scala | 15 |
3 files changed, 16 insertions, 6 deletions
diff --git a/src/actors/scala/actors/Reaction.scala b/src/actors/scala/actors/Reaction.scala index 97d0f10bc6..e3d9ae4b2e 100644 --- a/src/actors/scala/actors/Reaction.scala +++ b/src/actors/scala/actors/Reaction.scala @@ -34,7 +34,7 @@ private[actors] class ExitActorException extends Throwable * @version 0.9.8 * @author Philipp Haller */ -private[actors] class Reaction(a: Actor, +/*private[actors]*/ class Reaction(a: Actor, f: PartialFunction[Any, Unit], msg: Any) extends Runnable { def this(a: Actor) = this(a, null, null) diff --git a/src/actors/scala/actors/remote/RemoteActor.scala b/src/actors/scala/actors/remote/RemoteActor.scala index 0edd154c49..7bc3fc5a48 100644 --- a/src/actors/scala/actors/remote/RemoteActor.scala +++ b/src/actors/scala/actors/remote/RemoteActor.scala @@ -38,7 +38,7 @@ package scala.actors.remote * } * </pre> * - * @version 0.9.8 + * @version 0.9.9 * @author Philipp Haller */ object RemoteActor { @@ -50,8 +50,7 @@ object RemoteActor { * <code>port</code>. */ def alive(port: int): Unit = synchronized { - val serv = new TcpService(port) - serv.start() + val serv = TcpService(port) kernels += Actor.self -> serv.kernel } diff --git a/src/actors/scala/actors/remote/TcpService.scala b/src/actors/scala/actors/remote/TcpService.scala index d9181f96b6..d5a99ae7b5 100644 --- a/src/actors/scala/actors/remote/TcpService.scala +++ b/src/actors/scala/actors/remote/TcpService.scala @@ -20,11 +20,22 @@ import scala.collection.mutable.HashMap /* Object TcpService. * - * @version 0.9.8 + * @version 0.9.9 * @author Philipp Haller */ object TcpService { - val random = new Random + private val random = new Random + private val ports = new HashMap[Int, TcpService] + + def apply(port: Int): TcpService = + ports.get(port) match { + case Some(service) => service + case None => + val service = new TcpService(port) + ports += port -> service + service.start() + service + } def generatePort: Int = { var portnum = 0 |