38 #include <visp3/core/vpConfig.h>
40 #if defined(VISP_HAVE_PTHREAD) || (defined(_WIN32) && !defined(WINRT_8_0))
42 #if defined(VISP_HAVE_PTHREAD)
74 #if defined(VISP_HAVE_PTHREAD)
75 pthread_mutex_init(&m_mutex, NULL);
78 m_mutex = CreateMutexEx(NULL, NULL, 0, NULL);
80 m_mutex = CreateMutex(NULL,
84 if (m_mutex == NULL) {
85 std::cout <<
"CreateMutex error: " << GetLastError() << std::endl;
92 #if defined(VISP_HAVE_PTHREAD)
93 pthread_mutex_lock(&m_mutex);
97 dwWaitResult = WaitForSingleObjectEx(m_mutex, INFINITE, FALSE);
99 dwWaitResult = WaitForSingleObject(m_mutex,
102 if (dwWaitResult == WAIT_FAILED)
103 std::cout <<
"lock() error: " << GetLastError() << std::endl;
108 #if defined(VISP_HAVE_PTHREAD)
109 pthread_mutex_unlock(&m_mutex);
110 #elif defined(_WIN32)
112 if (!ReleaseMutex(m_mutex)) {
114 std::cout <<
"unlock() error: " << GetLastError() << std::endl;
186 #if defined(VISP_HAVE_PTHREAD)
187 pthread_mutex_t m_mutex;
188 #elif defined(_WIN32)
Class that allows protection by mutex.
vpScopedLock(vpMutex &mutex)
Constructor that locks the mutex.
virtual ~vpScopedLock()
Destructor that unlocks the mutex.