tuned signature in accordance to ML version;
authorwenzelm
Thu Apr 24 10:24:44 2014 +0200 (2014-04-24)
changeset 566877fb98325722a
parent 56686 2386d1a3ca8f
child 56688 f3932166a33d
tuned signature in accordance to ML version;
src/Pure/Concurrent/synchronized.scala
src/Pure/Concurrent/volatile.scala
src/Pure/PIDE/session.scala
src/Pure/System/event_bus.scala
     1.1 --- a/src/Pure/Concurrent/synchronized.scala	Thu Apr 24 00:29:55 2014 +0200
     1.2 +++ b/src/Pure/Concurrent/synchronized.scala	Thu Apr 24 10:24:44 2014 +0200
     1.3 @@ -17,9 +17,9 @@
     1.4  final class Synchronized[A] private(init: A)
     1.5  {
     1.6    private var state: A = init
     1.7 -  def apply(): A = synchronized { state }
     1.8 -  def >> (f: A => A) = synchronized { state = f(state) }
     1.9 -  def >>>[B] (f: A => (B, A)): B = synchronized {
    1.10 +  def value: A = synchronized { state }
    1.11 +  def change(f: A => A) = synchronized { state = f(state) }
    1.12 +  def change_result[B](f: A => (B, A)): B = synchronized {
    1.13      val (result, new_state) = f(state)
    1.14      state = new_state
    1.15      result
     2.1 --- a/src/Pure/Concurrent/volatile.scala	Thu Apr 24 00:29:55 2014 +0200
     2.2 +++ b/src/Pure/Concurrent/volatile.scala	Thu Apr 24 10:24:44 2014 +0200
     2.3 @@ -17,9 +17,9 @@
     2.4  final class Volatile[A] private(init: A)
     2.5  {
     2.6    @volatile private var state: A = init
     2.7 -  def apply(): A = state
     2.8 -  def >> (f: A => A) { state = f(state) }
     2.9 -  def >>>[B] (f: A => (B, A)): B =
    2.10 +  def value: A = state
    2.11 +  def change(f: A => A) { state = f(state) }
    2.12 +  def change_result[B](f: A => (B, A)): B =
    2.13    {
    2.14      val (result, new_state) = f(state)
    2.15      state = new_state
     3.1 --- a/src/Pure/PIDE/session.scala	Thu Apr 24 00:29:55 2014 +0200
     3.2 +++ b/src/Pure/PIDE/session.scala	Thu Apr 24 10:24:44 2014 +0200
     3.3 @@ -208,7 +208,7 @@
     3.4    /* global state */
     3.5  
     3.6    private val syslog = Volatile(Queue.empty[XML.Elem])
     3.7 -  def current_syslog(): String = cat_lines(syslog().iterator.map(XML.content))
     3.8 +  def current_syslog(): String = cat_lines(syslog.value.iterator.map(XML.content))
     3.9  
    3.10    @volatile private var _phase: Session.Phase = Session.Inactive
    3.11    private def phase_=(new_phase: Session.Phase)
    3.12 @@ -220,7 +220,7 @@
    3.13    def is_ready: Boolean = phase == Session.Ready
    3.14  
    3.15    private val global_state = Volatile(Document.State.init)
    3.16 -  def current_state(): Document.State = global_state()
    3.17 +  def current_state(): Document.State = global_state.value
    3.18  
    3.19    def recent_syntax(): Prover.Syntax =
    3.20    {
    3.21 @@ -230,7 +230,7 @@
    3.22  
    3.23    def snapshot(name: Document.Node.Name = Document.Node.Name.empty,
    3.24        pending_edits: List[Text.Edit] = Nil): Document.Snapshot =
    3.25 -    global_state().snapshot(name, pending_edits)
    3.26 +    global_state.value.snapshot(name, pending_edits)
    3.27  
    3.28  
    3.29    /* protocol handlers */
    3.30 @@ -290,7 +290,7 @@
    3.31            case output: Prover.Output =>
    3.32              buffer += msg
    3.33              if (output.is_syslog)
    3.34 -              syslog >> (queue =>
    3.35 +              syslog.change(queue =>
    3.36                  {
    3.37                    val queue1 = queue.enqueue(output.message)
    3.38                    if (queue1.length > syslog_limit) queue1.dequeue._2 else queue1
    3.39 @@ -357,9 +357,9 @@
    3.40      {
    3.41        prover.get.discontinue_execution()
    3.42  
    3.43 -      val previous = global_state().history.tip.version
    3.44 +      val previous = global_state.value.history.tip.version
    3.45        val version = Future.promise[Document.Version]
    3.46 -      val change = global_state >>> (_.continue_history(previous, edits, version))
    3.47 +      val change = global_state.change_result(_.continue_history(previous, edits, version))
    3.48  
    3.49        raw_edits.event(Session.Raw_Edits(doc_blobs, edits))
    3.50        change_parser ! Text_Edits(previous, doc_blobs, edits, version)
    3.51 @@ -376,19 +376,19 @@
    3.52        {
    3.53          for {
    3.54            digest <- command.blobs_digests
    3.55 -          if !global_state().defined_blob(digest)
    3.56 +          if !global_state.value.defined_blob(digest)
    3.57          } {
    3.58            change.doc_blobs.get(digest) match {
    3.59              case Some(blob) =>
    3.60 -              global_state >> (_.define_blob(digest))
    3.61 +              global_state.change(_.define_blob(digest))
    3.62                prover.get.define_blob(digest, blob.bytes)
    3.63              case None =>
    3.64                System.err.println("Missing blob for SHA1 digest " + digest)
    3.65            }
    3.66          }
    3.67  
    3.68 -        if (!global_state().defined_command(command.id)) {
    3.69 -          global_state >> (_.define_command(command))
    3.70 +        if (!global_state.value.defined_command(command.id)) {
    3.71 +          global_state.change(_.define_command(command))
    3.72            prover.get.define_command(command)
    3.73          }
    3.74        }
    3.75 @@ -397,8 +397,8 @@
    3.76            edit foreach { case (c1, c2) => c1 foreach id_command; c2 foreach id_command }
    3.77        }
    3.78  
    3.79 -      val assignment = global_state().the_assignment(change.previous).check_finished
    3.80 -      global_state >> (_.define_version(change.version, assignment))
    3.81 +      val assignment = global_state.value.the_assignment(change.previous).check_finished
    3.82 +      global_state.change(_.define_version(change.version, assignment))
    3.83        prover.get.update(change.previous.id, change.version.id, change.doc_edits)
    3.84        resources.commit(change)
    3.85      }
    3.86 @@ -419,7 +419,7 @@
    3.87        def accumulate(state_id: Document_ID.Generic, message: XML.Elem)
    3.88        {
    3.89          try {
    3.90 -          val st = global_state >>> (_.accumulate(state_id, message))
    3.91 +          val st = global_state.change_result(_.accumulate(state_id, message))
    3.92            delay_commands_changed.invoke(false, List(st.command))
    3.93          }
    3.94          catch {
    3.95 @@ -443,7 +443,7 @@
    3.96                  msg.text match {
    3.97                    case Protocol.Assign_Update(id, update) =>
    3.98                      try {
    3.99 -                      val cmds = global_state >>> (_.assign(id, update))
   3.100 +                      val cmds = global_state.change_result(_.assign(id, update))
   3.101                        delay_commands_changed.invoke(true, cmds)
   3.102                      }
   3.103                      catch { case _: Document.State.Fail => bad_output() }
   3.104 @@ -451,7 +451,7 @@
   3.105                  }
   3.106                  // FIXME separate timeout event/message!?
   3.107                  if (prover.isDefined && System.currentTimeMillis() > prune_next) {
   3.108 -                  val old_versions = global_state >>> (_.prune_history(prune_size))
   3.109 +                  val old_versions = global_state.change_result(_.prune_history(prune_size))
   3.110                    if (!old_versions.isEmpty) prover.get.remove_versions(old_versions)
   3.111                    prune_next = System.currentTimeMillis() + prune_delay.ms
   3.112                  }
   3.113 @@ -460,7 +460,7 @@
   3.114                  msg.text match {
   3.115                    case Protocol.Removed(removed) =>
   3.116                      try {
   3.117 -                      global_state >> (_.removed_versions(removed))
   3.118 +                      global_state.change(_.removed_versions(removed))
   3.119                      }
   3.120                      catch { case _: Document.State.Fail => bad_output() }
   3.121                    case _ => bad_output()
   3.122 @@ -511,7 +511,7 @@
   3.123          case Stop =>
   3.124            if (phase == Session.Ready) {
   3.125              _protocol_handlers = _protocol_handlers.stop(prover.get)
   3.126 -            global_state >> (_ => Document.State.init)  // FIXME event bus!?
   3.127 +            global_state.change(_ => Document.State.init)  // FIXME event bus!?
   3.128              phase = Session.Shutdown
   3.129              prover.get.terminate
   3.130              prover = None
   3.131 @@ -556,7 +556,7 @@
   3.132            }
   3.133  
   3.134          case change: Session.Change
   3.135 -        if prover.isDefined && global_state().is_assigned(change.previous) =>
   3.136 +        if prover.isDefined && global_state.value.is_assigned(change.previous) =>
   3.137            handle_change(change)
   3.138  
   3.139          case bad if !bad.isInstanceOf[Session.Change] =>
     4.1 --- a/src/Pure/System/event_bus.scala	Thu Apr 24 00:29:55 2014 +0200
     4.2 +++ b/src/Pure/System/event_bus.scala	Thu Apr 24 10:24:44 2014 +0200
     4.3 @@ -17,16 +17,16 @@
     4.4  
     4.5    private val receivers = Synchronized(List.empty[Actor])
     4.6  
     4.7 -  def += (r: Actor) { receivers >> (rs => Library.insert(r, rs)) }
     4.8 +  def += (r: Actor) { receivers.change(rs => Library.insert(r, rs)) }
     4.9  
    4.10    def += (f: Event => Unit) {
    4.11      this += actor { loop { react { case x => f(x.asInstanceOf[Event]) } } }
    4.12    }
    4.13  
    4.14 -  def -= (r: Actor) { receivers >> (rs => Library.remove(r, rs)) }
    4.15 +  def -= (r: Actor) { receivers.change(rs => Library.remove(r, rs)) }
    4.16  
    4.17  
    4.18    /* event invocation */
    4.19  
    4.20 -  def event(x: Event) { receivers().reverseIterator.foreach(_ ! x) }
    4.21 +  def event(x: Event) { receivers.value.reverseIterator.foreach(_ ! x) }
    4.22  }