new class: WaitHandleList helper for waiting on multiple events using the Win32 api.
This commit is contained in:
parent
f396965797
commit
2d420c0525
2 changed files with 57 additions and 0 deletions
31
waithandlelist.cpp
Normal file
31
waithandlelist.cpp
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#include "waithandlelist.h"
|
||||
#include "win32event.h"
|
||||
|
||||
WaitHandleList::WaitHandleList() = default;
|
||||
WaitHandleList::~WaitHandleList() = default;
|
||||
|
||||
WaitResultValue WaitHandleList::add(HANDLE h)
|
||||
{
|
||||
m_waitHandles.push_back(h);
|
||||
return WAIT_OBJECT_0 + static_cast<DWORD>(m_waitHandles.size() - 1);
|
||||
}
|
||||
|
||||
WaitResultValue WaitHandleList::add(Win32Event &e)
|
||||
{
|
||||
return add(e.handle());
|
||||
}
|
||||
|
||||
DWORD WaitHandleList::count() const
|
||||
{
|
||||
return static_cast<DWORD>(m_waitHandles.size());
|
||||
}
|
||||
|
||||
void WaitHandleList::clear()
|
||||
{
|
||||
m_waitHandles.clear();
|
||||
}
|
||||
|
||||
WaitHandleList::operator const HANDLE*() const
|
||||
{
|
||||
return m_waitHandles.data();
|
||||
}
|
||||
26
waithandlelist.h
Normal file
26
waithandlelist.h
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#ifndef WAITHANDLELIST_H
|
||||
#define WAITHANDLELIST_H
|
||||
|
||||
#include <windows.h>
|
||||
#include <vector>
|
||||
|
||||
class Win32Event;
|
||||
|
||||
using WaitResultValue = DWORD;
|
||||
|
||||
class WaitHandleList {
|
||||
public:
|
||||
WaitHandleList();
|
||||
~WaitHandleList();
|
||||
|
||||
WaitResultValue add(HANDLE h);
|
||||
WaitResultValue add(Win32Event &e);
|
||||
DWORD count() const;
|
||||
void clear();
|
||||
operator const HANDLE*() const;
|
||||
|
||||
private:
|
||||
std::vector<HANDLE> m_waitHandles;
|
||||
};
|
||||
|
||||
#endif // WAITHANDLELIST_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue