src/Pure/Build/build_process.scala
changeset 79770 5bcb1b368b30
parent 79768 7e05515cadc0
child 79771 48af00f6f110
equal deleted inserted replaced
79769:e9e74577755f 79770:5bcb1b368b30
  1124   }
  1124   }
  1125 
  1125 
  1126 
  1126 
  1127   /* run */
  1127   /* run */
  1128 
  1128 
  1129   protected def finished_unsynchronized(): Boolean =
  1129   def finished(): Boolean = synchronized {
  1130     if (!build_context.master && progress.stopped) _state.build_running.isEmpty
  1130     if (!build_context.master && progress.stopped) _state.build_running.isEmpty
  1131     else _state.pending.isEmpty
  1131     else _state.pending.isEmpty
       
  1132   }
  1132 
  1133 
  1133   protected def sleep(): Unit =
  1134   protected def sleep(): Unit =
  1134     Isabelle_Thread.interrupt_handler(_ => progress.stop()) { build_delay.sleep() }
  1135     Isabelle_Thread.interrupt_handler(_ => progress.stop()) { build_delay.sleep() }
  1135 
  1136 
  1136   def run(): Build.Results = {
  1137   def run(): Build.Results = {
  1137     var finished = false
  1138     val vacuous =
  1138 
  1139       synchronized_database("Build_Process.init") {
  1139     synchronized_database("Build_Process.init") {
  1140         if (build_context.master) {
  1140       if (build_context.master) {
  1141           _build_cluster.init()
  1141         _build_cluster.init()
  1142           _state = init_state(_state)
  1142         _state = init_state(_state)
  1143         }
  1143       }
  1144         _state = _state.copy(numa_nodes = Host.numa_nodes(enabled = build_context.numa_shuffling))
  1144       _state = _state.copy(numa_nodes = Host.numa_nodes(enabled = build_context.numa_shuffling))
  1145         build_context.master && _state.pending.isEmpty
  1145       finished = finished_unsynchronized()
  1146       }
  1146     }
       
  1147 
  1147 
  1148     def check_jobs_unsynchronized(): Boolean = {
  1148     def check_jobs_unsynchronized(): Boolean = {
  1149       val jobs = next_jobs(_state)
  1149       val jobs = next_jobs(_state)
  1150       for (name <- jobs) {
  1150       for (name <- jobs) {
  1151         if (is_session_name(name)) {
  1151         if (is_session_name(name)) {
  1160         else warning("Bad build job " + quote(name))
  1160         else warning("Bad build job " + quote(name))
  1161       }
  1161       }
  1162       jobs.nonEmpty
  1162       jobs.nonEmpty
  1163     }
  1163     }
  1164 
  1164 
  1165     if (finished) {
  1165     if (vacuous) {
  1166       progress.echo_warning("Nothing to build")
  1166       progress.echo_warning("Nothing to build")
  1167       Build.Results(build_context)
  1167       Build.Results(build_context)
  1168     }
  1168     }
  1169     else {
  1169     else {
  1170       if (build_context.master) start_build()
  1170       if (build_context.master) start_build()
  1171       start_worker()
  1171       start_worker()
  1172       _build_cluster.start()
  1172       _build_cluster.start()
  1173 
  1173 
  1174       try {
  1174       try {
  1175         while (!finished) {
  1175         while (!finished()) {
  1176           val check_jobs =
  1176           val check_jobs =
  1177             synchronized_database("Build_Process.main") {
  1177             synchronized_database("Build_Process.main") {
  1178               if (progress.stopped) _state.stop_running()
  1178               if (progress.stopped) _state.stop_running()
  1179 
  1179 
  1180               for (job <- _state.finished_running()) {
  1180               for (job <- _state.finished_running()) {
  1191                         result.output_shasum,
  1191                         result.output_shasum,
  1192                         node_info = job.node_info)
  1192                         node_info = job.node_info)
  1193                 }
  1193                 }
  1194               }
  1194               }
  1195 
  1195 
  1196               finished = finished_unsynchronized()
       
  1197               check_jobs_unsynchronized()
  1196               check_jobs_unsynchronized()
  1198             }
  1197             }
  1199 
  1198 
  1200           if (!check_jobs) sleep()
  1199           if (!check_jobs) sleep()
  1201         }
  1200         }