Hello,
In my threadpool engine the worker threads enters in a wait state
when there is no job in the lock-free queues - for more efficiency -
you can download the source code from:
http://pages.videotron.com/aminer/
but if you look at the threadpool engine source code i am using
the following code on the producer side:
---
events[local_balance].setevent;
---
and using the followingcode on the consumer side
:
---
if ThreadPool.Queues[self.threadcount].count <> 0
then continue;
for i:=0 to FThreadpool.Fthreadcount-1 do count:=count+FThreadPool.Queues[i].count;
if count=0 then
begin
FThreadpool.events[self.threadcount].waitfor(INFINITE);
FThreadpool.events[self.threadcount].resetevent;
end;
--
So a question follows..
If for example the consumer thread is on
FThreadpool.events[self.threadcount].waitfor(INFINITE);
and it receives two items before entering the
FThreadpool.events[self.threadcount].resetevent;
can it forget to process the second item cause the consumer thread
will reset the event but one item will still be on the queue...
Answer:
No, it will still process correctly the second item cause we arecatching
the number of items with the following code on the consumer side:
---
if ThreadPool.Queues[self.threadcount].count <> 0
then continue;
for i:=0 to FThreadpool.Fthreadcount-1 do count:=count+FThreadPool.Queues[i].count;
---
Thank you.
Amine Moulay Ramdane.



