From b1b53e115e18674ad147dabfcee57f6bdd813e4c Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Sat, 17 Jul 2010 12:07:41 -0400 Subject: [PATCH] first shot at general command/definition model --- util/control/ExitHook.scala | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/util/control/ExitHook.scala b/util/control/ExitHook.scala index 00f7b0d66..1e491b095 100644 --- a/util/control/ExitHook.scala +++ b/util/control/ExitHook.scala @@ -12,21 +12,11 @@ trait ExitHook extends NotNull def runBeforeExiting(): Unit } -trait ExitHookRegistry +object ExitHooks { - def register(hook: ExitHook): Unit - def unregister(hook: ExitHook): Unit -} - - -class ExitHooks extends ExitHookRegistry -{ - private val exitHooks = new scala.collection.mutable.HashSet[ExitHook] - def register(hook: ExitHook) { exitHooks += hook } - def unregister(hook: ExitHook) { exitHooks -= hook } /** Calls each registered exit hook, trapping any exceptions so that each hook is given a chance to run. */ - def runExitHooks(debug: String => Unit): List[Throwable] = - exitHooks.toList.flatMap( hook => + def runExitHooks(exitHooks: Seq[ExitHook]): Seq[Throwable] = + exitHooks.flatMap( hook => ErrorHandling.wideConvert( hook.runBeforeExiting() ).left.toOption ) } \ No newline at end of file