ReaderWriterLockImpl.h 760 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #pragma once
  2. #if IL2CPP_THREADS_WIN32
  3. #include "WindowsHeaders.h"
  4. namespace il2cpp
  5. {
  6. namespace os
  7. {
  8. class ReaderWriterLockImpl
  9. {
  10. public:
  11. ReaderWriterLockImpl()
  12. {
  13. InitializeSRWLock(&m_Lock);
  14. }
  15. void LockExclusive()
  16. {
  17. AcquireSRWLockExclusive(&m_Lock);
  18. }
  19. void LockShared()
  20. {
  21. AcquireSRWLockShared(&m_Lock);
  22. }
  23. void ReleaseExclusive()
  24. {
  25. ReleaseSRWLockExclusive(&m_Lock);
  26. }
  27. void ReleaseShared()
  28. {
  29. ReleaseSRWLockShared(&m_Lock);
  30. }
  31. PSRWLOCK GetOSHandle()
  32. {
  33. return &m_Lock;
  34. }
  35. private:
  36. SRWLOCK m_Lock;
  37. };
  38. }
  39. }
  40. #endif