Basically, I\'m looking to do something like this:
HANDLE hThread1 = CreateThread(...);
HANDLE hThread2 = CreateThread(...);
HANDLE hThread3 = CreateThread(.
Write a wrapper, then.
DWORD wait_for_multiple_objects(
std::initializer_list<HANDLE> handles,
bool wait_all = false, DWORD time = INFINITE
) {
return WaitForMultipleObjects(
handles.size(), &*handles.begin(), wait_all, time
);
}
Now you can do:
wait_for_multiple_objects({ handle1, handle2, handle3 });
This obviously requires C++11 compiler that supports initializer_list
. std::vector<HANDLE>
might be a better type for the argument if you expect to pass an already-existing one. Or a more generic iterator/range interface, but that's left as an exercise for the reader.