1 #include <msp/core/systemerror.h>
2 #include "eventobject.h"
4 #include "handle_private.h"
6 #include "poll_platform.h"
11 void Poller::rebuild_array()
13 priv->handles.clear();
15 for(EventMap::iterator i=objects.begin(); i!=objects.end(); ++i)
16 priv->handles.push_back(*i->first->get_event_handle());
21 void Poller::platform_poll(int timeout)
26 DWORD ret = WaitForMultipleObjects(priv->handles.size(), &priv->handles.front(), false, timeout);
27 if(/*ret>=WAIT_OBJECT_0 &&*/ ret<WAIT_OBJECT_0+priv->handles.size())
29 EventMap::iterator i = objects.begin();
30 advance(i, ret-WAIT_OBJECT_0);
31 poll_result.push_back(Slot(i->first, i->second));
33 else if(ret==WAIT_FAILED)
34 throw system_error("WaitForMultipleObjects");
38 PollEvent platform_poll(EventObject &obj, PollEvent pe, int timeout)
43 DWORD ret = WaitForSingleObject(*obj.get_event_handle(), timeout);
44 if(ret==WAIT_OBJECT_0)
46 else if(ret==WAIT_FAILED)
47 throw system_error("WaitForSingleObject");