为WaitforMultipleObject增加MAXIMUM_WAIT_OBJECTS [英] Increasing MAXIMUM_WAIT_OBJECTS for WaitforMultipleObjects

查看:342
本文介绍了为WaitforMultipleObject增加MAXIMUM_WAIT_OBJECTS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MAXIMUM_WAIT_OBJECTS 相比,等待更多对象的最简单方法是什么?
MSDN列出此:




  • 创建一个线程等待 MAXIMUM_WAIT_OBJECTS 句柄,然后等待那个线程加上其他句柄。使用此技术将句柄分成 MAXIMUM_WAIT_OBJECTS 组。

  • 调用 RegisterWaitForSingleObject 等待每个句柄。线程池中的等待线程等待 MAXIMUM_WAIT_OBJECTS 个注册对象,并在对象发出信号或超时间隔到期后分配工作线程。



但他们都不是很清楚。

解决方案

如果你发现自己在等待大量的对象您可能希望查看IO完成端口。对于大量的并行操作,IOCP的效率要高得多。



名称IOCP是误导性的,你可以很容易地使用IOCP为你自己的同步结构。 >

What is the simplest way to wait for more objects than MAXIMUM_WAIT_OBJECTS? MSDN lists this:

  • Create a thread to wait on MAXIMUM_WAIT_OBJECTS handles, then wait on that thread plus the other handles. Use this technique to break the handles into groups of MAXIMUM_WAIT_OBJECTS.
  • Call RegisterWaitForSingleObject to wait on each handle. A wait thread from the thread pool waits on MAXIMUM_WAIT_OBJECTS registered objects and assigns a worker thread after the object is signaled or the time-out interval expires.

But neither are them are very clear. The situation would be waiting for an array of over a thousand handles to threads.

解决方案

If you find yourself waiting on tons of objects you might want to look into IO Completion Ports instead. For large numbers of parallel operations IOCP is much more efficient.

And the name IOCP is misleading, you can easily use IOCP for your own synchronization structures as well.

这篇关于为WaitforMultipleObject增加MAXIMUM_WAIT_OBJECTS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆