Quote:
Originally Posted by hellrazor
But wasting 3 or 5 or 7 cores is totally effiecent, whatever you say.
|
Assuming there is more than one logical processor in the first place. If there isn't, you added inefficiency in the name of efficiency!
Quote:
Originally Posted by Aquinus
Also to your queue argument. You need to lock down the queue every time you push or pull an item out of the queue because you're altering it and a race condition wouldn't just be bad for the application, it could corrupt the queue.
|
A main thread could manage the queue (push work on and pop it off to be sent to another thread) but if those results have to come back in the same order they were sent (which should, because why else would you be using a queue?) multithreading the queue will be a disaster.
FYI, instead of locks, I use events so instead of locking memory by a thread, I always make the thread that owns it perform the update. The weakest link becomes the main thread though because if it gets spammed with work to do by worker threads, the whole thing slows to a crawl (the main thread and all of the worker threads).