1

Regarding IOCP and Threadpools, should I use a specific function to create a "thread pool"?

Right now I create my "thread pool" by calling CreateThread as many times as the number of threads I want in the pool.

I then assumed that all the threads created with CreateThread should call GetQueuedCompletionStatus and that's actually the call that creates the "thread pool"? (By associating the threads with a specific port) The threadpool = the threads associated with the IOCP?

Arre
  • 125
  • 1
  • 7
  • The threads for an IOCP thread pool can come from anywhere. CreateThread is a perfectly valid way of doing it. The act of calling GetQueuedCompletionStatus is what associates the thread with the IOCP. – Raymond Chen May 30 '20 at 17:55
  • Hello @RaymondChen Allright, but why do I want the threads to be associated with the port? What is the purpose? Does it have to do with LIFO?... That all the threads calling GetQueuedCompletionStatus gets in the LIFO queue? (The first thread that moves on from GetQueuedCompletionStatus is the one that last called it) – Arre May 30 '20 at 18:14
  • Presumably you want the threads to have IOCP completions dispatched to them. Why else would you call GetQueuedCompletionStatus? – Raymond Chen May 31 '20 at 00:34
  • you can create and pop packets from iocp by self. or use system thread pool for this (old by `BindIoCompletionCallback` and new by `CreateThreadpoolIo`). but your question is uncler. about what you asking ? how lifo here related and why you worried about this ? – RbMm May 31 '20 at 10:13

0 Answers0