diff options
author | Paul Phillips <paulp@improving.org> | 2010-11-17 01:00:57 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-11-17 01:00:57 +0000 |
commit | 363a1456f671323b35dcacf2c8b8eb39180b8a53 (patch) | |
tree | 553913c9a121fa5595a95d40e59c5d9f6944d64c /src/compiler/scala/tools/nsc/io/package.scala | |
parent | b7fcc7c73e41b326fe4d85d81c49c50fa954c990 (diff) | |
download | scala-363a1456f671323b35dcacf2c8b8eb39180b8a53.tar.gz scala-363a1456f671323b35dcacf2c8b8eb39180b8a53.tar.bz2 scala-363a1456f671323b35dcacf2c8b8eb39180b8a53.zip |
Two annoying REPL things made less annoying:
* ctrl-C will no longer kill the repl unless you hit it again
* ctrl-Z will no longer make the repl useless because of jline
In the service of the first I wrote signal handling code, which we can
put to use in other ways as well. No review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/io/package.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/io/package.scala | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/io/package.scala b/src/compiler/scala/tools/nsc/io/package.scala index 2016fb5518..1d484a6c0e 100644 --- a/src/compiler/scala/tools/nsc/io/package.scala +++ b/src/compiler/scala/tools/nsc/io/package.scala @@ -6,6 +6,7 @@ package scala.tools.nsc import java.util.concurrent.{ Future, Callable, Executors } +import java.util.{ Timer, TimerTask } package object io { def runnable(body: => Unit): Runnable = new Runnable { override def run() = body } @@ -24,4 +25,13 @@ package object io { thread.start thread } + + // Set a timer to execute the given code. + def timer(seconds: Int)(body: => Unit): Timer = { + val alarm = new Timer(true) // daemon + val tt = new TimerTask { def run() = body } + + alarm.schedule(tt, seconds * 1000) + alarm + } }
\ No newline at end of file |