diff options
Diffstat (limited to 'K2LABI/Common/windows-adapter.cpp')
-rw-r--r-- | K2LABI/Common/windows-adapter.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/K2LABI/Common/windows-adapter.cpp b/K2LABI/Common/windows-adapter.cpp new file mode 100644 index 0000000..6236010 --- /dev/null +++ b/K2LABI/Common/windows-adapter.cpp @@ -0,0 +1,42 @@ +// +// windows-adapter.cpp +// AmbientLight +// +// Created by Thorsten Kummermehr on 10/9/13. +// +// + +#include "windows-adapter.h" + +void InitializeCriticalSection( LPCRITICAL_SECTION lpCriticalSection ) +{ + if (NULL == lpCriticalSection) + return; + pthread_mutexattr_t mutexattr; + + // Set the mutex as a recursive mutex + pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_RECURSIVE); + + pthread_mutex_init(&lpCriticalSection->m_mutex, &mutexattr); + + // destroy the attribute + pthread_mutexattr_destroy(&mutexattr); + +} + +void DeleteCriticalSection(LPCRITICAL_SECTION lpCriticalSection) +{ + if (NULL == lpCriticalSection) + return; + pthread_mutex_destroy (&lpCriticalSection->m_mutex); +} + +void EnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection) +{ + pthread_mutex_lock (&lpCriticalSection->m_mutex); +} + +void LeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection) +{ + pthread_mutex_unlock (&lpCriticalSection->m_mutex); +}
\ No newline at end of file |