I have created a small DLL that creats threads to do slow
network tasks, however, I wanted to put a thread pool control
into it e.g. I request 100 threads to run but only have 10
at anyone time. So I did som'it like the following
'Implement a currently running thread pool manager
DO WHILE ThreadCnt > %MaxConcurrentThreads
CALL SwitchToThread
LOOP
THREAD CREATE ThreadRoutine(pHeap) TO hThreadID
IF hThreadID <> 0 THEN
CALL WaitForSingleObject(ThreadCntMutex, 1000)' %INFINITE)
INCR ThreadCnt
CALL ReleaseMutex(ThreadCntMutex)
END IF
Then in the ThreadRoutine I have
CALL WaitForSingleObject(ThreadCntMutex, %INFINITE)
DECR ThreadCnt
CALL ReleaseMutex(ThreadCntMutex)
ExitThread 0
The problem is that when it gets into the Do loop, the child threads
don't appear to get a look in, hense, they can't do their bit
and exit..........
what am I missing ???
------------------
network tasks, however, I wanted to put a thread pool control
into it e.g. I request 100 threads to run but only have 10
at anyone time. So I did som'it like the following
'Implement a currently running thread pool manager
DO WHILE ThreadCnt > %MaxConcurrentThreads
CALL SwitchToThread
LOOP
THREAD CREATE ThreadRoutine(pHeap) TO hThreadID
IF hThreadID <> 0 THEN
CALL WaitForSingleObject(ThreadCntMutex, 1000)' %INFINITE)
INCR ThreadCnt
CALL ReleaseMutex(ThreadCntMutex)
END IF
Then in the ThreadRoutine I have
CALL WaitForSingleObject(ThreadCntMutex, %INFINITE)
DECR ThreadCnt
CALL ReleaseMutex(ThreadCntMutex)
ExitThread 0
The problem is that when it gets into the Do loop, the child threads
don't appear to get a look in, hense, they can't do their bit
and exit..........
what am I missing ???
------------------
Comment