Generic event bus.
authorwenzelm
Mon, 29 Dec 2008 13:57:37 +0100
changeset 29190 89217ccfd130
parent 29188 ff41885a1234
child 29191 de56edf88514
Generic event bus.
src/Pure/General/event_bus.scala
src/Pure/IsaMakefile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Pure/General/event_bus.scala	Mon Dec 29 13:57:37 2008 +0100
@@ -0,0 +1,20 @@
+/*  Title:      Pure/General/event_bus.scala
+    Author:     Makarius
+
+Generic event bus.
+*/
+
+package isabelle
+
+import scala.collection.jcl.LinkedList
+
+
+class EventBus[Event] {
+  type Handler = Event => Unit
+  private val handlers = new LinkedList[Handler]
+
+  def += (h: Handler) = synchronized { handlers -= h; handlers += h }
+  def -= (h: Handler) = synchronized { handlers -= h }
+
+  def event(e: Event) = synchronized { for(h <- handlers) h(e) }
+}
--- a/src/Pure/IsaMakefile	Sun Dec 28 14:41:47 2008 -0800
+++ b/src/Pure/IsaMakefile	Mon Dec 29 13:57:37 2008 +0100
@@ -121,10 +121,11 @@
 
 ## Scala material
 
-SCALA_FILES = General/markup.scala General/position.scala		\
-  General/symbol.scala General/xml.scala General/yxml.scala		\
-  Isar/isar.scala Thy/thy_header.scala Tools/isabelle_process.scala	\
-  Tools/isabelle_syntax.scala Tools/isabelle_system.scala
+SCALA_FILES = General/event_bus.scala General/markup.scala	\
+  General/position.scala General/symbol.scala General/xml.scala	\
+  General/yxml.scala Isar/isar.scala Thy/thy_header.scala	\
+  Tools/isabelle_process.scala Tools/isabelle_syntax.scala	\
+  Tools/isabelle_system.scala
 
 
 SCALA_TARGET = $(ISABELLE_HOME)/lib/classes/Pure.jar