void Win32TestHierarchySandboxRunnerImpl:: process(TestHierarchyHandler* handler) { setupListeners(); DWORD result = ::WaitForMultipleObjects ( sandboxes.size()*2 , handles , FALSE , INFINITE); if(result == WAIT_FAILED) { throwLastError(); } if(WAIT_OBJECT_0 > result || result >= WAIT_OBJECT_0 + sandboxes.size() * 2) { throw Error("Invalid WaitForMultipleObjects result"); } handleEvent ( (result-WAIT_OBJECT_0)/2 , (result-WAIT_OBJECT_0)%2>0 ? true : false , handler); }
void Gosu::Win::handleMessage() { MSG message; BOOL ret = ::GetMessage(&message, 0, 0, 0); switch (ret) { case -1: { // GetMessage() failed. throwLastError("trying to get the next message"); } case 0: { // GetMessage() found a WM_QUIT message. // IMPR: Is there a better way to respond to this? break; } default: { // Normal behaviour, if the message does not get handled by // something else. if (!handledByHook(message)) { ::TranslateMessage(&message); ::DispatchMessage(&message); } } } }
void InterfaceESCC::doOpen(void) { #if defined(DUNE_OS_LINUX) if (m_handle != -1) ::close(m_handle); m_handle = ::open(m_dev.c_str(), O_RDWR); if (m_handle == -1) throwLastError("failed to open ESCC device"); #else throw std::runtime_error("unsupported operation"); #endif }
unsigned InterfaceESCC::doRead(uint8_t* data, unsigned data_size) { #if defined(DUNE_OS_LINUX) ssize_t rv = ::read(m_handle, data, data_size); if (rv <= 0) throwLastError("read failure"); return (unsigned)rv; #else (void)data; (void)data_size; return 0; #endif }
ESCC::ESCC(const std::string& dev): m_dev(dev), m_handle(-1) { #if defined(DUNE_OS_LINUX) if (m_handle != -1) ::close(m_handle); m_handle = ::open(m_dev.c_str(), O_RDWR); if (m_handle == -1) throwLastError("failed to open ESCC device"); #else throw std::runtime_error("unsupported operation"); #endif }
inline T check(T valToCheck, const std::string& action = "") { if (!valToCheck) throwLastError(action); return valToCheck; }