0

I have one confusion relating to IOCP (among so many others) as I am fairly new to multi-threaded programming. Can we not use IOCP without having to associate them with a device like a file/port/namedpipe etc.?

What I really want to do is to build a library that implements a Thread pool which caters to Queues with different priorities. Anyone using my library should be able to pass any function and any parameters - these may not just be reads and writes of IOs. IOCP seems to be the best for efficient management of a threadpool except that I need to associate a device with it. What if I am not working with files or communication over network? Maybe I just need different clients to perform different functions using thread pool, perhaps on the same machine? How can I workaround that?

Any hints, ideas, pointers will be much appreciated. Thanks for your help in advance, and kindly excuse my ignorance on this topic.

Ngage
  • 1
  • 1
  • I'd suggest starting with the [Thread Pool](https://learn.microsoft.com/en-us/windows/win32/procthread/thread-pools) docs. – Mgetz Nov 14 '21 at 12:46
  • PostQueuedCompletionStatus lets you post non-I/O work to an IOCP. – Raymond Chen Nov 14 '21 at 13:02
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Nov 16 '21 at 13:54
  • @RaymondChen Thanks for the input. That seems promising. So do I still need the overlapped structure and the completion key? In that case, do I need to manage the threads in the threadpool myself? – Ngage Nov 23 '21 at 05:32
  • [From the documentation](https://learn.microsoft.com/en-us/windows/win32/fileio/postqueuedcompletionstatus): "In particular, the lpOverlapped parameter need not point to an OVERLAPPED structure." And you have always been responsible for managing the threads in the IOCP. PostQueuedCompletionStatus doesn't change that. – Raymond Chen Nov 23 '21 at 15:27

0 Answers0