avoid exhaustion of worker threads, notably due to complex interaction of future/promise/lazy in Proofterm.make_thm_node;
--- a/src/Pure/Concurrent/future.ML Wed Aug 05 12:42:43 2020 +0200
+++ b/src/Pure/Concurrent/future.ML Wed Aug 05 16:16:37 2020 +0200
@@ -320,11 +320,14 @@
val max_active0 = ! max_active;
val max_workers0 = ! max_workers;
+ val workers_waiting = count_workers Waiting;
+
val m =
if ! do_shutdown andalso Task_Queue.all_passive (! queue) then 0
else Multithreading.max_threads ();
val _ = max_active := m;
- val _ = max_workers := 2 * m;
+ val _ = max_workers :=
+ Int.max (2 * m, if workers_waiting > 0 then workers_waiting + 1 else 0);
val missing = ! max_workers - length (! workers);
val _ =