src/Pure/System/isabelle_process.scala
changeset 75393 87ebf5a50283
parent 73897 0ddb5de0506e
child 76488 1eed7e1300ed
equal deleted inserted replaced
75388:b3ca4a6ed74b 75393:87ebf5a50283
     9 
     9 
    10 import java.util.{Map => JMap}
    10 import java.util.{Map => JMap}
    11 import java.io.{File => JFile}
    11 import java.io.{File => JFile}
    12 
    12 
    13 
    13 
    14 object Isabelle_Process
    14 object Isabelle_Process {
    15 {
       
    16   def start(
    15   def start(
    17     session: Session,
    16     session: Session,
    18     options: Options,
    17     options: Options,
    19     sessions_structure: Sessions.Structure,
    18     sessions_structure: Sessions.Structure,
    20     store: Sessions.Store,
    19     store: Sessions.Store,
    22     raw_ml_system: Boolean = false,
    21     raw_ml_system: Boolean = false,
    23     use_prelude: List[String] = Nil,
    22     use_prelude: List[String] = Nil,
    24     eval_main: String = "",
    23     eval_main: String = "",
    25     modes: List[String] = Nil,
    24     modes: List[String] = Nil,
    26     cwd: JFile = null,
    25     cwd: JFile = null,
    27     env: JMap[String, String] = Isabelle_System.settings()): Isabelle_Process =
    26     env: JMap[String, String] = Isabelle_System.settings()
    28   {
    27   ): Isabelle_Process = {
    29     val channel = System_Channel()
    28     val channel = System_Channel()
    30     val process =
    29     val process =
    31       try {
    30       try {
    32         val channel_options =
    31         val channel_options =
    33           options.string.update("system_channel_address", channel.address).
    32           options.string.update("system_channel_address", channel.address).
    45 
    44 
    46     isabelle_process
    45     isabelle_process
    47   }
    46   }
    48 }
    47 }
    49 
    48 
    50 class Isabelle_Process private(session: Session, process: Bash.Process)
    49 class Isabelle_Process private(session: Session, process: Bash.Process) {
    51 {
       
    52   private val startup = Future.promise[String]
    50   private val startup = Future.promise[String]
    53   private val terminated = Future.promise[Process_Result]
    51   private val terminated = Future.promise[Process_Result]
    54 
    52 
    55   session.phase_changed +=
    53   session.phase_changed +=
    56     Session.Consumer(getClass.getName) {
    54     Session.Consumer(getClass.getName) {
    70     startup.join match {
    68     startup.join match {
    71       case "" => this
    69       case "" => this
    72       case err => session.stop(); error(err)
    70       case err => session.stop(); error(err)
    73     }
    71     }
    74 
    72 
    75   def await_shutdown(): Process_Result =
    73   def await_shutdown(): Process_Result = {
    76   {
       
    77     val result = terminated.join
    74     val result = terminated.join
    78     session.stop()
    75     session.stop()
    79     result
    76     result
    80   }
    77   }
    81 
    78