123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- #include "il2cpp-config.h"
- #include "os/Mutex.h"
- #if IL2CPP_SUPPORT_THREADS
- #include "os/Atomic.h"
- #if IL2CPP_THREADS_WIN32
- #include "os/Win32/MutexImpl.h"
- #elif IL2CPP_TARGET_PSP2
- #include "os/PSP2/MutexImpl.h"
- #elif IL2CPP_THREADS_PTHREAD
- #include "os/Posix/MutexImpl.h"
- #else
- #include "os/MutexImpl.h"
- #endif
- namespace il2cpp
- {
- namespace os
- {
- Mutex::Mutex(bool initiallyOwned)
- : m_Mutex(new MutexImpl())
- {
- if (initiallyOwned)
- Lock();
- }
- Mutex::~Mutex()
- {
- delete m_Mutex;
- }
- void Mutex::Lock(bool interruptible)
- {
- m_Mutex->Lock(interruptible);
- }
- bool Mutex::TryLock(uint32_t milliseconds, bool interruptible)
- {
- return m_Mutex->TryLock(milliseconds, interruptible);
- }
- void Mutex::Unlock()
- {
- m_Mutex->Unlock();
- }
- void* Mutex::GetOSHandle()
- {
- return m_Mutex->GetOSHandle();
- }
- FastMutex::FastMutex()
- : m_Impl(new FastMutexImpl())
- {
- }
- FastMutex::~FastMutex()
- {
- delete m_Impl;
- }
- void FastMutex::Lock()
- {
- m_Impl->Lock();
- }
- void FastMutex::Unlock()
- {
- m_Impl->Unlock();
- }
- FastMutexImpl* FastMutex::GetImpl()
- {
- return m_Impl;
- }
- }
- }
- #else
- namespace il2cpp
- {
- namespace os
- {
- Mutex::Mutex(bool initiallyOwned)
- {
- }
- Mutex::~Mutex()
- {
- }
- void Mutex::Lock(bool interruptible)
- {
- }
- bool Mutex::TryLock(uint32_t milliseconds, bool interruptible)
- {
- return true;
- }
- void Mutex::Unlock()
- {
- }
- void* Mutex::GetOSHandle()
- {
- return NULL;
- }
- FastMutex::FastMutex()
- {
- }
- FastMutex::~FastMutex()
- {
- }
- void FastMutex::Lock()
- {
- }
- void FastMutex::Unlock()
- {
- }
- FastMutexImpl* FastMutex::GetImpl()
- {
- IL2CPP_ASSERT(0 && "Threads are not enabled for this platform.");
- return NULL;
- }
- }
- }
- #endif
|