我现在的策略:
将所有对对象按64个一组,分成N组。然后,使用一个比较小的时间间隔(例如:2秒)等待每一组对象,直到以下情况出现:
1.总等待达到规定的等待时间。
2.有一个对象in the signaled state
但是,我觉得这种方法效率太低,希望有更好的策略。背景资料:
WaitForMultipleObjects
DWORD WaitForMultipleObjects(
DWORD nCount, // number of handles in array
CONST HANDLE *lpHandles, // object-handle array
BOOL bWaitAll, // wait option
DWORD dwMilliseconds // time-out interval
);nCount
[in] Specifies the number of object handles in the array pointed to by lpHandles. The maximum number of object handles is MAXIMUM_WAIT_OBJECTS. <winnt.h>
#define MAXIMUM_WAIT_OBJECTS 64 // Maximum number of wait objects
将所有对对象按64个一组,分成N组。然后,使用一个比较小的时间间隔(例如:2秒)等待每一组对象,直到以下情况出现:
1.总等待达到规定的等待时间。
2.有一个对象in the signaled state
但是,我觉得这种方法效率太低,希望有更好的策略。背景资料:
WaitForMultipleObjects
DWORD WaitForMultipleObjects(
DWORD nCount, // number of handles in array
CONST HANDLE *lpHandles, // object-handle array
BOOL bWaitAll, // wait option
DWORD dwMilliseconds // time-out interval
);nCount
[in] Specifies the number of object handles in the array pointed to by lpHandles. The maximum number of object handles is MAXIMUM_WAIT_OBJECTS. <winnt.h>
#define MAXIMUM_WAIT_OBJECTS 64 // Maximum number of wait objects
就可以了. 与操作系统无关的.
另外可以采用共享内存的方式,将各个对象在共享内存中进行记录标志,
可以方便很多。基本上没有什么上限