From: Jack on 21 Apr 2010 23:32 Dear all, As my game application require more than 12 mobile units to do pathfinding at the same time, I wonder if I implement a thread pool (and that means to use a task queue for awaiting tasks) for those objects, would that really affect the overall performance of the application? ( I mean some objects would wait for their turns and standing still for a couple of minutes) And are there any good examples to demostrate how to use a thread pool? I looked codeguru and code project and I want some more examples. Thanks Jack
From: Jack on 21 Apr 2010 23:49 Also if contrarly, If I implement 12 independent threads for each object. Would that be too insane and totally bog down for a single core CPU? Thanks Jack
From: Faisal on 22 Apr 2010 08:04 From Win2000 onwards windows provides thread pool http://msdn.microsoft.com/en-us/library/ms686760%28VS.85%29.aspx Note that these APIs have undergone some significant changes in Windows Vista. If you are trying implement thread pool by your own, use the concept of IO completion ports. You can create a number of threads( better a number slightly bigger than your number of CPUs) and let all these threads wait on IOCP using GetQueuedCompletionStatus(). When a task is to be done, queue a request to IOCP using PostQueuedCompletionStatus(). On this one thread from the pool will wake up from wait and you can do the job there. You would have to device an appropriate data structure to queue requests. Fellow MVP Dr. Newcomer has some excelent article on IOCP in his site. http://www.flounder.com/mvp_tips.htm
From: Jack on 22 Apr 2010 08:29 Hi Faisal, Lots of thanks for the links. Now I am digging into them.... Jack
|
Pages: 1 Prev: memory fragmentation Next: Different speeds required for 2 simultaneous threads |