windows.handle.h.xml 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <chapter xml:id="windows.handle.h">
  2. <title><tt>__vic/windows/handle.h</tt></title>
  3. <chapter xml:id="windows--Handle">
  4. <title><tt>windows::Handle</tt></title>
  5. <code-block lang="C++"><![CDATA[
  6. class windows::Handle
  7. {
  8. public:
  9. Handle() = default; // uninitialized
  10. constexpr Handle(HANDLE h);
  11. void Close();
  12. bool CloseNT() noexcept;
  13. static void Close(HANDLE h);
  14. bool Wait(DWORD timeout = INFINITE) const;
  15. bool IsInvalid() const;
  16. void SetInvalid();
  17. operator HANDLE() const;
  18. void swap(Handle &o) noexcept;
  19. };
  20. ]]></code-block>
  21. <p>A C++ wrapper for Win32 API <tt>HANDLE</tt>.</p>
  22. <section><title>Class members</title>
  23. <synopsis>
  24. <prototype>Handle() = default</prototype>
  25. <p>Creates an uninitialized value.</p>
  26. </synopsis>
  27. <synopsis>
  28. <prototype>constexpr Handle(HANDLE h)</prototype>
  29. <p>Implicit converter from <tt>HANDLE</tt>.</p>
  30. <postcondition><tt>*this == h</tt></postcondition>
  31. </synopsis>
  32. <synopsis>
  33. <prototype>operator HANDLE() const</prototype>
  34. <p>Implicit converter to <tt>HANDLE</tt>.</p>
  35. </synopsis>
  36. <synopsis>
  37. <prototype>bool IsInvalid() const</prototype>
  38. <p>Returns <tt>true</tt> if the handle has value <tt>INVALID_HANDLE_VALUE</tt>.
  39. </p>
  40. </synopsis>
  41. <synopsis>
  42. <prototype>void SetInvalid()</prototype>
  43. <p>Assigns value <tt>INVALID_HANDLE_VALUE</tt> to the handle.</p>
  44. <postcondition><tt>IsInvalid() == true</tt></postcondition>
  45. </synopsis>
  46. <synopsis>
  47. <prototype>void Close()</prototype>
  48. <prototype>static void Close(HANDLE h)</prototype>
  49. <p>Calls <tt>::CloseHandle()</tt>. Throws on error.</p>
  50. <precondition>The same as for <tt>::CloseHandle()</tt>.</precondition>
  51. </synopsis>
  52. <synopsis>
  53. <prototype>bool CloseNT() noexcept</prototype>
  54. <p>Calls <tt>::CloseHandle()</tt> and returns <tt>true</tt> on success.
  55. On failure <tt>::GetLastError()</tt> can be used to get the error
  56. description.</p>
  57. <precondition>The same as for <tt>::CloseHandle()</tt>.</precondition>
  58. </synopsis>
  59. <synopsis>
  60. <prototype>bool Wait(DWORD timeout = INFINITE) const</prototype>
  61. <p>Calls <tt>::WaitForSingleObject()</tt> with the specified timeout. Returns
  62. <tt>false</tt> in case of <tt>WAIT_TIMEOUT</tt>. Throws on error.
  63. <xref to="windows--WaitAbandoned"/> is thrown in case of
  64. <tt>WAIT_ABANDONED</tt>.</p>
  65. </synopsis>
  66. <synopsis>
  67. <prototype>void swap(Handle &amp;o) noexcept</prototype>
  68. <p>Swaps the value with <tt>o</tt>.</p>
  69. </synopsis>
  70. </section>
  71. </chapter>
  72. <chapter xml:id="windows--WaitAbandoned">
  73. <title><tt>windows::WaitAbandoned</tt></title>
  74. <code-block lang="C++"><![CDATA[
  75. struct windows::WaitAbandoned : public std::exception
  76. {
  77. const char *what() const noexcept;
  78. };
  79. ]]></code-block>
  80. <p>An exception class thrown by <tt>__vic::windows::Handle::Wait()</tt>.</p>
  81. </chapter>
  82. </chapter>