Attachment "tpoolcmd.diff" to
ticket [d9c95d3ed3]
added by
bovine
2016-11-12 03:54:00.
diff --git a/generic/threadPoolCmd.c b/generic/threadPoolCmd.c
index 4fc3d86..58d088a 100644
--- a/generic/threadPoolCmd.c
+++ b/generic/threadPoolCmd.c
@@ -386,28 +386,23 @@ TpoolPostObjCmd(dummy, interp, objc, objv)
Tcl_MutexLock(&tpoolPtr->mutex);
if (nowait) {
- if (tpoolPtr->numWorkers == 0) {
+ /*
+ * If there are no idle worker threads, start some new
+ * unless we are already running max number of workers.
+ * In that case don't wait and just queue the job.
+ */
+
+ if (tpoolPtr->idleWorkers == 0 &&
+ tpoolPtr->numWorkers < tpoolPtr->maxWorkers) {
/*
- * Assure there is at least one worker running.
+ * No more free workers; start new one
*/
- PushWaiter(tpoolPtr);
if (CreateWorker(interp, tpoolPtr) != TCL_OK) {
Tcl_MutexUnlock(&tpoolPtr->mutex);
return TCL_ERROR;
}
-
- /*
- * Wait for worker to start while servicing the event loop
- */
-
- Tcl_MutexUnlock(&tpoolPtr->mutex);
- tsdPtr->stop = -1;
- while(tsdPtr->stop == -1) {
- Tcl_DoOneEvent(TCL_ALL_EVENTS);
- }
- Tcl_MutexLock(&tpoolPtr->mutex);
}
} else {