event_bus.scala rather belongs to system plumbing;
authorwenzelm
Sun Aug 15 23:13:56 2010 +0200 (2010-08-15)
changeset 38428c13c95c97e89
parent 38427 7066fbd315ae
child 38429 9951852fae91
event_bus.scala rather belongs to system plumbing;
src/Pure/PIDE/event_bus.scala
src/Pure/System/event_bus.scala
src/Pure/build-jars
     1.1 --- a/src/Pure/PIDE/event_bus.scala	Sun Aug 15 23:07:22 2010 +0200
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,35 +0,0 @@
     1.4 -/*  Title:      Pure/PIDE/event_bus.scala
     1.5 -    Author:     Makarius
     1.6 -
     1.7 -Generic event bus with multiple receiving actors.
     1.8 -*/
     1.9 -
    1.10 -package isabelle
    1.11 -
    1.12 -import scala.actors.Actor, Actor._
    1.13 -import scala.collection.mutable.ListBuffer
    1.14 -
    1.15 -
    1.16 -class Event_Bus[Event]
    1.17 -{
    1.18 -  /* receivers */
    1.19 -
    1.20 -  private val receivers = new ListBuffer[Actor]
    1.21 -
    1.22 -  def += (r: Actor) { synchronized { receivers += r } }
    1.23 -  def + (r: Actor): Event_Bus[Event] = { this += r; this }
    1.24 -
    1.25 -  def += (f: Event => Unit) {
    1.26 -    this += actor { loop { react { case x: Event => f(x) } } }
    1.27 -  }
    1.28 -
    1.29 -  def + (f: Event => Unit): Event_Bus[Event] = { this += f; this }
    1.30 -
    1.31 -  def -= (r: Actor) { synchronized { receivers -= r } }
    1.32 -  def - (r: Actor) = { this -= r; this }
    1.33 -
    1.34 -
    1.35 -  /* event invocation */
    1.36 -
    1.37 -  def event(x: Event) { synchronized { receivers.foreach(_ ! x) } }
    1.38 -}
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/src/Pure/System/event_bus.scala	Sun Aug 15 23:13:56 2010 +0200
     2.3 @@ -0,0 +1,35 @@
     2.4 +/*  Title:      Pure/System/event_bus.scala
     2.5 +    Author:     Makarius
     2.6 +
     2.7 +Generic event bus with multiple receiving actors.
     2.8 +*/
     2.9 +
    2.10 +package isabelle
    2.11 +
    2.12 +import scala.actors.Actor, Actor._
    2.13 +import scala.collection.mutable.ListBuffer
    2.14 +
    2.15 +
    2.16 +class Event_Bus[Event]
    2.17 +{
    2.18 +  /* receivers */
    2.19 +
    2.20 +  private val receivers = new ListBuffer[Actor]
    2.21 +
    2.22 +  def += (r: Actor) { synchronized { receivers += r } }
    2.23 +  def + (r: Actor): Event_Bus[Event] = { this += r; this }
    2.24 +
    2.25 +  def += (f: Event => Unit) {
    2.26 +    this += actor { loop { react { case x: Event => f(x) } } }
    2.27 +  }
    2.28 +
    2.29 +  def + (f: Event => Unit): Event_Bus[Event] = { this += f; this }
    2.30 +
    2.31 +  def -= (r: Actor) { synchronized { receivers -= r } }
    2.32 +  def - (r: Actor) = { this -= r; this }
    2.33 +
    2.34 +
    2.35 +  /* event invocation */
    2.36 +
    2.37 +  def event(x: Event) { synchronized { receivers.foreach(_ ! x) } }
    2.38 +}
     3.1 --- a/src/Pure/build-jars	Sun Aug 15 23:07:22 2010 +0200
     3.2 +++ b/src/Pure/build-jars	Sun Aug 15 23:13:56 2010 +0200
     3.3 @@ -39,11 +39,11 @@
     3.4    Isar/token.scala
     3.5    PIDE/command.scala
     3.6    PIDE/document.scala
     3.7 -  PIDE/event_bus.scala
     3.8    PIDE/markup_node.scala
     3.9    PIDE/text.scala
    3.10    System/cygwin.scala
    3.11    System/download.scala
    3.12 +  System/event_bus.scala
    3.13    System/gui_setup.scala
    3.14    System/isabelle_process.scala
    3.15    System/isabelle_syntax.scala