SignaledEvent.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright (c) 2014, Oculus VR, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the BSD-style license found in the
  6. * LICENSE file in the root directory of this source tree. An additional grant
  7. * of patent rights can be found in the PATENTS file in the same directory.
  8. *
  9. */
  10. #ifndef __SIGNALED_EVENT_H
  11. #define __SIGNALED_EVENT_H
  12. #if defined(_WIN32)
  13. #include "WindowsIncludes.h"
  14. #else
  15. #include <pthread.h>
  16. #include <sys/types.h>
  17. #include "SimpleMutex.h"
  18. #endif
  19. #include "Export.h"
  20. namespace RakNet
  21. {
  22. class RAK_DLL_EXPORT SignaledEvent
  23. {
  24. public:
  25. SignaledEvent();
  26. ~SignaledEvent();
  27. void InitEvent(void);
  28. void CloseEvent(void);
  29. void SetEvent(void);
  30. void WaitOnEvent(int timeoutMs);
  31. protected:
  32. #ifdef _WIN32
  33. HANDLE eventList;
  34. #else
  35. SimpleMutex isSignaledMutex;
  36. bool isSignaled;
  37. #if !defined(ANDROID)
  38. pthread_condattr_t condAttr;
  39. #endif
  40. pthread_cond_t eventList;
  41. pthread_mutex_t hMutex;
  42. pthread_mutexattr_t mutexAttr;
  43. #endif
  44. };
  45. } // namespace RakNet
  46. #endif
粤ICP备19079148号