Since the maximum size of these is known in advance, and fixed by the
implementation, I think it would be better to avoid the constant
allocation and deallocation of these arrays, and instead have static
arrays of their maximum size.
+static void
+CleanupWaitForMultipleObjectsInfo (WaitForMultipleObjectsInfo *p)
+{
+ SetEvent (p->hEndEvent);
+ WaitForMultipleObjects(p->nThread, p->hObjects, TRUE, INFINITE);
+
+ xfree (p->hObjects);
+ xfree (p->pHandles);
+ xfree (p->pParams);
+ CloseHandle (p->hEndEvent);
+ for (int i = 0; i < p->nThread; i++)
+ CloseHandle (p->hObjects[i]);
+ return;
+}
IIUC, this will cause us starting 2 threads when we need to start 65
processes. Wouldn't it be better to use just one thread, and wait for
the other processes as we do now using the rest of available slots in
the wait_hnd[] array?
Finally, is it known how long it takes on a modern Windows system to
start a thread? This could be important for assessing the impact of
this design on the performance of sub-processes on MS-Windows.