Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #1712
| From | "aminer" <aminer@videotron.ca> |
|---|---|
| Newsgroups | comp.programming.threads, comp.programming |
| Subject | About my threadpool engine... |
| Date | 2012-06-03 11:09 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <jqfumj$r5a$1@dont-email.me> (permalink) |
Cross-posted to 2 groups.
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 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; 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 are catching 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.
Back to comp.programming | Previous | Next — Next in thread | Find similar
About my threadpool engine... "aminer" <aminer@videotron.ca> - 2012-06-03 11:09 -0500 Re: About my threadpool engine... "aminer" <aminer@videotron.ca> - 2012-06-03 11:31 -0500
csiph-web