src/Pure/System/progress.scala
changeset 61276 8a4bd05c1735
child 64049 ac3ed62c53c3
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/Pure/System/progress.scala	Tue Sep 29 13:54:04 2015 +0200
     1.3 @@ -0,0 +1,33 @@
     1.4 +/*  Title:      Pure/System/progress.scala
     1.5 +    Author:     Makarius
     1.6 +
     1.7 +Progress context for system processes.
     1.8 +*/
     1.9 +
    1.10 +package isabelle
    1.11 +
    1.12 +
    1.13 +class Progress
    1.14 +{
    1.15 +  def echo(msg: String) {}
    1.16 +  def theory(session: String, theory: String) {}
    1.17 +  def stopped: Boolean = false
    1.18 +  override def toString: String = if (stopped) "Progress(stopped)" else "Progress"
    1.19 +}
    1.20 +
    1.21 +object Ignore_Progress extends Progress
    1.22 +
    1.23 +class Console_Progress(verbose: Boolean = false) extends Progress
    1.24 +{
    1.25 +  override def echo(msg: String) { Console.println(msg) }
    1.26 +  override def theory(session: String, theory: String): Unit =
    1.27 +    if (verbose) echo(session + ": theory " + theory)
    1.28 +
    1.29 +  @volatile private var is_stopped = false
    1.30 +  def interrupt_handler[A](e: => A): A = POSIX_Interrupt.handler { is_stopped = true } { e }
    1.31 +  override def stopped: Boolean =
    1.32 +  {
    1.33 +    if (Thread.interrupted) is_stopped = true
    1.34 +    is_stopped
    1.35 +  }
    1.36 +}