diff options
author | Philipp Haller <hallerp@gmail.com> | 2007-09-18 12:02:32 +0000 |
---|---|---|
committer | Philipp Haller <hallerp@gmail.com> | 2007-09-18 12:02:32 +0000 |
commit | d3b1c7957eea64ba4c2dc7729696a97f15590bf8 (patch) | |
tree | abfa19532899e5fe13214552922318ed56866ab1 | |
parent | 00eed346f23a1aaff3b9e4722a70ffcd499600c2 (diff) | |
download | scala-d3b1c7957eea64ba4c2dc7729696a97f15590bf8.tar.gz scala-d3b1c7957eea64ba4c2dc7729696a97f15590bf8.tar.bz2 scala-d3b1c7957eea64ba4c2dc7729696a97f15590bf8.zip |
Added clearProxy method to Actor object.
-rw-r--r-- | src/actors/scala/actors/Actor.scala | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/actors/scala/actors/Actor.scala b/src/actors/scala/actors/Actor.scala index cba7a8c4c0..3f1d6bf161 100644 --- a/src/actors/scala/actors/Actor.scala +++ b/src/actors/scala/actors/Actor.scala @@ -57,6 +57,21 @@ object Actor { } /** + * Removes any reference to an <code>ActorProxy</code> + * currently stored in thread-local storage. + * + * This allows to release references from threads that are + * potentially long-running or being re-used (e.g. inside + * a thread pool). Permanent references in thread-local storage + * are a potential memory leak. + */ + def clearProxy { + val a = tl.get.asInstanceOf[Actor] + if ((null ne a) && a.isInstanceOf[ActorProxy]) + tl.set(null) + } + + /** * <p>This function is used for the definition of actors.</p> * <p>The following example demonstrates its usage:</p><pre> * import scala.actors.Actor._ |