1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- #ifndef MUTEX_UTILS_H
- #define MUTEX_UTILS_H
- #include "core/error_macros.h"
- #include "core/os/mutex.h"
- #include "macros.h"
- class ScopedMutexLock {
- Mutex *mutex;
- public:
- ScopedMutexLock(Mutex *mutex) {
- this->mutex = mutex;
- #ifndef NO_THREADS
- #ifdef DEBUG_ENABLED
- CRASH_COND(!mutex);
- #endif
- this->mutex->lock();
- #endif
- }
- ~ScopedMutexLock() {
- #ifndef NO_THREADS
- #ifdef DEBUG_ENABLED
- CRASH_COND(!mutex);
- #endif
- mutex->unlock();
- #endif
- }
- };
- #define SCOPED_MUTEX_LOCK(m_mutex) ScopedMutexLock GD_UNIQUE_NAME(__scoped_mutex_lock__)(m_mutex);
- #endif
|