EventImpl.h 939 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #pragma once
  2. #if (IL2CPP_THREADS_PTHREAD || IL2CPP_THREADS_WIN32) && !RUNTIME_TINY
  3. #include "os/ErrorCodes.h"
  4. #include "os/WaitStatus.h"
  5. #include "os/Generic/WaitObject.h"
  6. namespace il2cpp
  7. {
  8. namespace os
  9. {
  10. class EventImpl : public WaitObject
  11. {
  12. public:
  13. EventImpl(bool manualReset, bool signaled)
  14. : WaitObject(manualReset ? kManualResetEvent : kAutoResetEvent)
  15. {
  16. if (signaled)
  17. m_Count = 1;
  18. }
  19. ~EventImpl()
  20. {
  21. }
  22. ErrorCode Set()
  23. {
  24. WaitObject::ReleaseOnDestroy lock(m_Mutex);
  25. m_Count = 1;
  26. if (HaveWaitingThreads())
  27. WakeupAllThreads();
  28. return kErrorCodeSuccess;
  29. }
  30. ErrorCode Reset()
  31. {
  32. WaitObject::ReleaseOnDestroy lock(m_Mutex);
  33. m_Count = 0;
  34. return kErrorCodeSuccess;
  35. }
  36. };
  37. }
  38. }
  39. #endif