33 #include "safec_lib.h"
35 #include "osal/Util.hpp"
37 CCEC_OSAL_BEGIN_NAMESPACE
39 Mutex::Mutex(
void) : nativeHandle(NULL)
41 pthread_mutexattr_t attr;
42 nativeHandle = Malloc(
sizeof(pthread_mutex_t));
43 pthread_mutexattr_init( &attr);
44 pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE_NP);
45 pthread_mutex_init( (pthread_mutex_t *) nativeHandle, &attr );
46 pthread_mutexattr_destroy(&attr);
51 nativeHandle = Malloc(
sizeof(pthread_mutex_t));
52 MEMCPY_S(nativeHandle,
sizeof(pthread_mutex_t), rhs.nativeHandle,
sizeof(pthread_mutex_t));
55 Mutex & Mutex::operator = (
const Mutex &rhs)
58 void *tempHandle = temp.nativeHandle;
59 temp.nativeHandle = nativeHandle;
60 nativeHandle = tempHandle;
67 if (nativeHandle != NULL) {
68 pthread_mutex_destroy((pthread_mutex_t *) nativeHandle);
75 pthread_mutex_lock((pthread_mutex_t *)nativeHandle);
80 pthread_mutex_unlock((pthread_mutex_t *)nativeHandle);
88 CCEC_OSAL_END_NAMESPACE