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()) { |