windows_handle_wait.cpp 801 B

1234567891011121314151617181920212223242526272829
  1. //
  2. // $Id$
  3. //
  4. #include<__vic/windows/handle.h>
  5. #include<__vic/error.h>
  6. #include<__vic/string_buffer.h>
  7. #include<__vic/windows/throw_last_error.h>
  8. #include<windows.h>
  9. namespace __vic { namespace windows {
  10. //----------------------------------------------------------------------------
  11. bool Handle::Wait(DWORD timeout) const
  12. {
  13. switch(DWORD res = ::WaitForSingleObject(h, timeout))
  14. {
  15. case WAIT_OBJECT_0: return true;
  16. case WAIT_TIMEOUT: return false;
  17. case WAIT_ABANDONED: throw WaitAbandoned();
  18. case WAIT_FAILED: throw_last_error("WaitForSingleObject");
  19. default: throw exception(__vic::msg(64) <<
  20. "WaitForSingleObject status is " << res);
  21. }
  22. }
  23. //----------------------------------------------------------------------------
  24. }} // namespace