43 #include <visp3/core/vpConfig.h> 45 #if defined(VISP_HAVE_PTHREAD) || (defined(_WIN32) && !defined(WINRT_8_0)) 47 #if defined(VISP_HAVE_PTHREAD) 79 #if defined(VISP_HAVE_PTHREAD) 80 pthread_mutex_init(&m_mutex, NULL);
83 m_mutex = CreateMutexEx(NULL, NULL, 0, NULL);
85 m_mutex = CreateMutex(NULL,
89 if (m_mutex == NULL) {
90 std::cout <<
"CreateMutex error: " << GetLastError() << std::endl;
97 #if defined(VISP_HAVE_PTHREAD) 98 pthread_mutex_lock(&m_mutex);
102 dwWaitResult = WaitForSingleObjectEx(m_mutex, INFINITE, FALSE);
104 dwWaitResult = WaitForSingleObject(m_mutex,
107 if (dwWaitResult == WAIT_FAILED)
108 std::cout <<
"lock() error: " << GetLastError() << std::endl;
113 #if defined(VISP_HAVE_PTHREAD) 114 pthread_mutex_unlock(&m_mutex);
115 #elif defined(_WIN32) 117 if (!ReleaseMutex(m_mutex)) {
119 std::cout <<
"unlock() error: " << GetLastError() << std::endl;
191 #if defined(VISP_HAVE_PTHREAD) 192 pthread_mutex_t m_mutex;
193 #elif defined(_WIN32) Class that allows protection by mutex.
~vpScopedLock()
Destructor that unlocks the mutex.
vpScopedLock(vpMutex &mutex)
Constructor that locks the mutex.