简体   繁体   English

如何为完成端口创建多个线程?

[英]How to create multiple threads for the completion port?

Multiple threads can dequeue completion packets from a single completion port using the GetQueuedCompletionStatus() function. 多个线程可以使用GetQueuedCompletionStatus()函数从单个完成端口出队完成数据包。 Is there a special function that creates these threads? 是否有创建这些线程的特殊功能? Or I simply use for example CreateThread() or _beginthreadex() and create as much threads as I need? 或者我只是使用例如CreateThread()_beginthreadex()并根据需要创建尽可能多的线程?

There is nothing special about a thread that calls GetQueuedCompletionStatus() on a given IOCP. 在给定的IOCP上调用GetQueuedCompletionStatus()的线程没有什么特别的。 Any thread can do it. 任何线程都可以做到。 Therefore you can create your "I/O threads" using the usual thread creation functions. 因此,您可以使用常规的线程创建功能来创建“ I / O线程”。 In general it's best to use _beginthreadex() unless you're writing code for platforms that do not support it OR you are not linking with the CRT. 通常,最好使用_beginthreadex()除非您正在为不支持该平台的平台编写代码,或者您未与CRT链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM