diff options
author | Philipp Haller <hallerp@gmail.com> | 2007-04-26 09:30:50 +0000 |
---|---|---|
committer | Philipp Haller <hallerp@gmail.com> | 2007-04-26 09:30:50 +0000 |
commit | 99630e293745f07ac3e88582872230c015a4f963 (patch) | |
tree | 2c74a122fbe6f10a3749d49fd054633449b80a96 /src/actors | |
parent | b7e87847c73d44b7448f7774204cb3e342958d9b (diff) | |
download | scala-99630e293745f07ac3e88582872230c015a4f963.tar.gz scala-99630e293745f07ac3e88582872230c015a4f963.tar.bz2 scala-99630e293745f07ac3e88582872230c015a4f963.zip |
Added resetProxy method that replaces an implic...
Added resetProxy method that replaces an implicit ActorProxy with a new
instance.
Diffstat (limited to 'src/actors')
-rw-r--r-- | src/actors/scala/actors/Actor.scala | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/actors/scala/actors/Actor.scala b/src/actors/scala/actors/Actor.scala index cfb2041d64..bf1917afbf 100644 --- a/src/actors/scala/actors/Actor.scala +++ b/src/actors/scala/actors/Actor.scala @@ -43,6 +43,20 @@ object Actor { } /** + * Resets an actor proxy associated with the current thread. + * It replaces the implicit <code>ActorProxy</code> instance + * of the current thread (if any) with a new instance. + * + * This permits to re-use the current thread as an actor + * even if its <code>ActorProxy</code> has died for some reason. + */ + def resetProxy: unit = synchronized { + val a = tl.get.asInstanceOf[Actor] + if ((null ne a) && a.isInstanceOf[ActorProxy]) + tl.set(new ActorProxy(currentThread)) + } + + /** * <p>This function is used for the definition of actors.</p> * <p>The following example demonstrates its usage:</p><pre> * import scala.actors.Actor._ |