platform_mutex.h (423B)
1 #pragma once 2 3 #include "platform.h" 4 5 #if PLATFORM_WINDOWS 6 #include "win32_mutex.h" 7 #elif PLATFORM_UNIX 8 #include "unix_mutex.h" 9 #else 10 #error new platform 11 #endif 12 13 struct ScopedMutexLock { 14 Mutex * mutex; 15 16 ScopedMutexLock( Mutex * mtx ) { 17 mutex = mtx; 18 mutex_lock( mutex ); 19 } 20 21 ~ScopedMutexLock() { 22 mutex_unlock( mutex ); 23 } 24 }; 25 26 #define SCOPED_MUTEX_LOCK( mutex ) ScopedMutexLock COUNTER_NAME( scoped_mutex )( mutex );