From ef70e6174d4b373a601b73757ca19bb0f7dd6502 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Mon, 20 Jul 2009 10:25:02 +0200 Subject: architecture change: queue now always has at least one worker thread ...if not running in direct mode. Previous versions could run without any active workers. This simplifies the code at a very small expense. See v5 compatibility note document for more in-depth discussion. --- runtime/wtp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'runtime/wtp.c') diff --git a/runtime/wtp.c b/runtime/wtp.c index e1ebcd4c..e8bc5120 100644 --- a/runtime/wtp.c +++ b/runtime/wtp.c @@ -381,7 +381,9 @@ wtpStartWrkr(wtp_t *pThis, int bLockMutex) if(i == pThis->iNumWorkerThreads) ABORT_FINALIZE(RS_RET_NO_MORE_THREADS); - pThis->iCurNumWrkThrd++; /* we got one more! */ + if(i == 0 || pThis->toWrkShutdown == -1) { + wtiSetAlwaysRunning(pThis->pWrkr[i]); + } pWti = pThis->pWrkr[i]; wtiSetState(pWti, WRKTHRD_RUNNING); @@ -389,6 +391,8 @@ wtpStartWrkr(wtp_t *pThis, int bLockMutex) pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); iState = pthread_create(&(pWti->thrdID), &attr, wtpWorker, (void*) pWti); pthread_attr_destroy(&attr); /* TODO: we could globally reuse such an attribute 2009-07-08 */ + pThis->iCurNumWrkThrd++; /* we got one more! */ + dbgprintf("%s: started with state %d, num workers now %d\n", wtpGetDbgHdr(pThis), iState, pThis->iCurNumWrkThrd); -- cgit