src/Pure/PIDE/headless.scala
changeset 69013 bb4e4c253ebe
parent 69012 c91d14ab065f
child 69032 90bb4cabe1e8
equal deleted inserted replaced
69012:c91d14ab065f 69013:bb4e4c253ebe
    63     val snapshot = state.snapshot(name)
    63     val snapshot = state.snapshot(name)
    64     assert(version.id == snapshot.version.id)
    64     assert(version.id == snapshot.version.id)
    65     snapshot
    65     snapshot
    66   }
    66   }
    67 
    67 
    68   class Theories_Result private[Headless](
    68   class Use_Theories_Result private[Headless](
    69     val state: Document.State,
    69     val state: Document.State,
    70     val version: Document.Version,
    70     val version: Document.Version,
    71     val nodes: List[(Document.Node.Name, Document_Status.Node_Status)],
    71     val nodes: List[(Document.Node.Name, Document_Status.Node_Status)],
    72     val nodes_committed: List[(Document.Node.Name, Document_Status.Node_Status)])
    72     val nodes_committed: List[(Document.Node.Name, Document_Status.Node_Status)])
    73   {
    73   {
   113 
   113 
   114     private sealed case class Use_Theories_State(
   114     private sealed case class Use_Theories_State(
   115       last_update: Time = Time.now(),
   115       last_update: Time = Time.now(),
   116       nodes_status: Document_Status.Nodes_Status = Document_Status.Nodes_Status.empty,
   116       nodes_status: Document_Status.Nodes_Status = Document_Status.Nodes_Status.empty,
   117       already_committed: Map[Document.Node.Name, Document_Status.Node_Status] = Map.empty,
   117       already_committed: Map[Document.Node.Name, Document_Status.Node_Status] = Map.empty,
   118       result: Promise[Theories_Result] = Future.promise[Theories_Result])
   118       result: Promise[Use_Theories_Result] = Future.promise[Use_Theories_Result])
   119     {
   119     {
   120       def update(new_nodes_status: Document_Status.Nodes_Status): Use_Theories_State =
   120       def update(new_nodes_status: Document_Status.Nodes_Status): Use_Theories_State =
   121         copy(last_update = Time.now(), nodes_status = new_nodes_status)
   121         copy(last_update = Time.now(), nodes_status = new_nodes_status)
   122 
   122 
   123       def watchdog(watchdog_timeout: Time): Boolean =
   123       def watchdog(watchdog_timeout: Time): Boolean =
   124         watchdog_timeout > Time.zero && Time.now() - last_update > watchdog_timeout
   124         watchdog_timeout > Time.zero && Time.now() - last_update > watchdog_timeout
   125 
   125 
   126       def cancel_result { result.cancel }
   126       def cancel_result { result.cancel }
   127       def finished_result: Boolean = result.is_finished
   127       def finished_result: Boolean = result.is_finished
   128       def await_result { result.join_result }
   128       def await_result { result.join_result }
   129       def join_result: Theories_Result = result.join
   129       def join_result: Use_Theories_Result = result.join
   130       def check_result(
   130       def check_result(
   131           state: Document.State,
   131           state: Document.State,
   132           version: Document.Version,
   132           version: Document.Version,
   133           dep_theories: List[Document.Node.Name],
   133           dep_theories: List[Document.Node.Name],
   134           beyond_limit: Boolean,
   134           beyond_limit: Boolean,
   171             for {
   171             for {
   172               name <- dep_theories
   172               name <- dep_theories
   173               status <- already_committed.get(name)
   173               status <- already_committed.get(name)
   174             } yield (name -> status)
   174             } yield (name -> status)
   175 
   175 
   176           try { result.fulfill(new Theories_Result(state, version, nodes, nodes_committed)) }
   176           try { result.fulfill(new Use_Theories_Result(state, version, nodes, nodes_committed)) }
   177           catch { case _: IllegalStateException => }
   177           catch { case _: IllegalStateException => }
   178         }
   178         }
   179 
   179 
   180         st1
   180         st1
   181       }
   181       }
   191       nodes_status_delay: Time = default_nodes_status_delay,
   191       nodes_status_delay: Time = default_nodes_status_delay,
   192       id: UUID = UUID(),
   192       id: UUID = UUID(),
   193       // commit: must not block, must not fail
   193       // commit: must not block, must not fail
   194       commit: Option[(Document.Snapshot, Document_Status.Node_Status) => Unit] = None,
   194       commit: Option[(Document.Snapshot, Document_Status.Node_Status) => Unit] = None,
   195       commit_cleanup_delay: Time = default_commit_cleanup_delay,
   195       commit_cleanup_delay: Time = default_commit_cleanup_delay,
   196       progress: Progress = No_Progress): Theories_Result =
   196       progress: Progress = No_Progress): Use_Theories_Result =
   197     {
   197     {
   198       val dep_theories =
   198       val dep_theories =
   199       {
   199       {
   200         val import_names =
   200         val import_names =
   201           theories.map(thy =>
   201           theories.map(thy =>