1 #include <msp/core/systemerror.h>
2 #include "eventobject.h"
4 #include "handle_private.h"
6 #include "poll_platform.h"
13 void Poller::rebuild_array()
18 priv->handles.clear();
19 priv->handles.reserve(objects.size());
21 for(vector<PolledObject>::const_iterator i=objects.begin(); i!=objects.end(); ++i)
22 priv->handles.push_back(*i->object->get_event_handle());
25 void Poller::platform_poll(int timeout)
30 DWORD ret = WaitForMultipleObjects(priv->handles.size(), &priv->handles.front(), false, timeout);
31 if(/*ret>=WAIT_OBJECT_0 &&*/ ret<WAIT_OBJECT_0+priv->handles.size())
33 const PolledObject &obj = objects[ret-WAIT_OBJECT_0];
34 poll_result.push_back(obj);
36 else if(ret==WAIT_FAILED)
37 throw system_error("WaitForMultipleObjects");
41 PollEvent platform_poll(EventObject &obj, PollEvent pe, int timeout)
46 DWORD ret = WaitForSingleObject(*obj.get_event_handle(), timeout);
47 if(ret==WAIT_OBJECT_0)
49 else if(ret==WAIT_FAILED)
50 throw system_error("WaitForSingleObject");