Event_WIN32.h 996 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. //
  2. // Event_WIN32.h
  3. //
  4. // Library: Foundation
  5. // Package: Threading
  6. // Module: Event
  7. //
  8. // Definition of the EventImpl class for WIN32.
  9. //
  10. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
  11. // and Contributors.
  12. //
  13. // SPDX-License-Identifier: BSL-1.0
  14. //
  15. #ifndef Foundation_Event_WIN32_INCLUDED
  16. #define Foundation_Event_WIN32_INCLUDED
  17. #include "Poco/Foundation.h"
  18. #include "Poco/Exception.h"
  19. #include "Poco/UnWindows.h"
  20. namespace Poco {
  21. class Foundation_API EventImpl
  22. {
  23. protected:
  24. EventImpl(bool autoReset);
  25. ~EventImpl();
  26. void setImpl();
  27. void waitImpl();
  28. bool waitImpl(long milliseconds);
  29. void resetImpl();
  30. private:
  31. HANDLE _event;
  32. };
  33. //
  34. // inlines
  35. //
  36. inline void EventImpl::setImpl()
  37. {
  38. if (!SetEvent(_event))
  39. {
  40. throw SystemException("cannot signal event");
  41. }
  42. }
  43. inline void EventImpl::resetImpl()
  44. {
  45. if (!ResetEvent(_event))
  46. {
  47. throw SystemException("cannot reset event");
  48. }
  49. }
  50. } // namespace Poco
  51. #endif // Foundation_Event_WIN32_INCLUDED