summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/util/package.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-12-04 19:33:47 +0000
committerPaul Phillips <paulp@improving.org>2010-12-04 19:33:47 +0000
commit32ca2f2be6a027e2112bc1f8e10f99571caa4a8c (patch)
tree6d0fe6cfac2815088cfe09fe9bb23089109fc337 /src/compiler/scala/tools/nsc/util/package.scala
parentb1e969a11b2b24f5883198dc0b90d9ab5513498b (diff)
downloadscala-32ca2f2be6a027e2112bc1f8e10f99571caa4a8c.tar.gz
scala-32ca2f2be6a027e2112bc1f8e10f99571caa4a8c.tar.bz2
scala-32ca2f2be6a027e2112bc1f8e10f99571caa4a8c.zip
Introducing scala.system, the product of a whir...
Introducing scala.system, the product of a whirlwind couple of hours. More useful stuff than you can shake three sticks at. See the scala.system package object. It's even documented. And since it has methods error and exit, proceeded to deprecate the ones in Predef. No review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/util/package.scala')
-rw-r--r--src/compiler/scala/tools/nsc/util/package.scala24
1 files changed, 2 insertions, 22 deletions
diff --git a/src/compiler/scala/tools/nsc/util/package.scala b/src/compiler/scala/tools/nsc/util/package.scala
index 800cb75b97..b61f3751b9 100644
--- a/src/compiler/scala/tools/nsc/util/package.scala
+++ b/src/compiler/scala/tools/nsc/util/package.scala
@@ -13,33 +13,13 @@ package object util {
/** Apply a function and return the passed value */
def returning[T](x: T)(f: T => Unit): T = { f(x) ; x }
- /** Register a shutdown hook to be run when the jvm exits.
- * Marks it as daemon so it doesn't interfere with shutdown,
- * but the thread is returned so it can be modified.
- */
- def addShutdownHook(body: => Unit) = {
- returning(new Thread { override def run { body } }) { t =>
- t setDaemon true
- Runtime.getRuntime addShutdownHook t
- }
- }
-
- /** All living threads. */
- def allThreads(): List[Thread] = {
- val num = Thread.activeCount()
- val tarray = new Array[Thread](num)
- val got = Thread.enumerate(tarray)
-
- tarray take got toList
- }
-
/** Execute code and then wait for all Threads created during its
* execution to complete.
*/
def waitingForThreads[T](body: => T) = {
- val ts1 = allThreads()
+ val ts1 = system.allThreads()
val result = body
- val ts2 = allThreads()
+ val ts2 = system.allThreads()
val newThreads = ts2.toSet -- ts1 filterNot (_.isDaemon())
newThreads foreach (_.join())