36 } |
36 } |
37 |
37 |
38 class Progress { |
38 class Progress { |
39 def echo(message: Progress.Message) = {} |
39 def echo(message: Progress.Message) = {} |
40 |
40 |
41 def echo(msg: String): Unit = |
41 final def echo(msg: String): Unit = |
42 echo(Progress.Message(Progress.Kind.writeln, msg)) |
42 echo(Progress.Message(Progress.Kind.writeln, msg)) |
43 def echo_warning(msg: String): Unit = |
43 final def echo_warning(msg: String): Unit = |
44 echo(Progress.Message(Progress.Kind.warning, msg)) |
44 echo(Progress.Message(Progress.Kind.warning, msg)) |
45 def echo_error_message(msg: String): Unit = |
45 final def echo_error_message(msg: String): Unit = |
46 echo(Progress.Message(Progress.Kind.error_message, msg)) |
46 echo(Progress.Message(Progress.Kind.error_message, msg)) |
47 |
47 |
48 def echo_if(cond: Boolean, msg: String): Unit = if (cond) echo(msg) |
48 final def echo_if(cond: Boolean, msg: String): Unit = if (cond) echo(msg) |
49 |
49 |
50 def verbose: Boolean = false |
50 def verbose: Boolean = false |
51 def theory(theory: Progress.Theory): Unit = if (verbose) echo(theory.message) |
51 def theory(theory: Progress.Theory): Unit = if (verbose) echo(theory.message) |
52 |
52 |
53 def nodes_status(nodes_status: Document_Status.Nodes_Status): Unit = {} |
53 def nodes_status(nodes_status: Document_Status.Nodes_Status): Unit = {} |
54 |
54 |
55 def timeit[A](body: => A, message: Exn.Result[A] => String = null, enabled: Boolean = true): A = |
55 final def timeit[A]( |
56 Timing.timeit(body, message = message, enabled = enabled, output = echo) |
56 body: => A, |
|
57 message: Exn.Result[A] => String = null, |
|
58 enabled: Boolean = true |
|
59 ): A = Timing.timeit(body, message = message, enabled = enabled, output = echo) |
57 |
60 |
58 @volatile protected var is_stopped = false |
61 @volatile protected var is_stopped = false |
59 def stop(): Unit = { is_stopped = true } |
62 def stop(): Unit = { is_stopped = true } |
60 def stopped: Boolean = { |
63 def stopped: Boolean = { |
61 if (Thread.interrupted()) is_stopped = true |
64 if (Thread.interrupted()) is_stopped = true |
62 is_stopped |
65 is_stopped |
63 } |
66 } |
64 |
67 |
65 def interrupt_handler[A](e: => A): A = POSIX_Interrupt.handler { stop() } { e } |
68 final def interrupt_handler[A](e: => A): A = POSIX_Interrupt.handler { stop() } { e } |
66 def expose_interrupt(): Unit = if (stopped) throw Exn.Interrupt() |
69 final def expose_interrupt(): Unit = if (stopped) throw Exn.Interrupt() |
67 override def toString: String = if (stopped) "Progress(stopped)" else "Progress" |
70 override def toString: String = if (stopped) "Progress(stopped)" else "Progress" |
68 |
71 |
69 def bash(script: String, |
72 final def bash(script: String, |
70 cwd: JFile = null, |
73 cwd: JFile = null, |
71 env: JMap[String, String] = Isabelle_System.settings(), |
74 env: JMap[String, String] = Isabelle_System.settings(), |
72 redirect: Boolean = false, |
75 redirect: Boolean = false, |
73 echo: Boolean = false, |
76 echo: Boolean = false, |
74 watchdog: Time = Time.zero, |
77 watchdog: Time = Time.zero, |