MutexImpl.h 720 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #pragma once
  2. #if IL2CPP_THREADS_WIN32
  3. #include "os/Win32/WindowsHeaders.h"
  4. namespace il2cpp
  5. {
  6. namespace os
  7. {
  8. class FastMutexImpl
  9. {
  10. public:
  11. FastMutexImpl()
  12. {
  13. InitializeCriticalSection(&m_CritialSection);
  14. }
  15. ~FastMutexImpl()
  16. {
  17. DeleteCriticalSection(&m_CritialSection);
  18. }
  19. void Lock()
  20. {
  21. EnterCriticalSection(&m_CritialSection);
  22. }
  23. void Unlock()
  24. {
  25. LeaveCriticalSection(&m_CritialSection);
  26. }
  27. CRITICAL_SECTION* GetOSHandle()
  28. {
  29. return &m_CritialSection;
  30. }
  31. private:
  32. CRITICAL_SECTION m_CritialSection;
  33. };
  34. }
  35. }
  36. #endif