42 #include <visp3/core/vpConfig.h>
45 #if defined(VISP_HAVE_PTHREAD) || (defined(_WIN32) && !defined(WINRT_8_0))
47 #if defined(VISP_HAVE_PTHREAD)
73 #if defined(VISP_HAVE_PTHREAD)
74 pthread_mutex_init( &m_mutex, NULL );
77 m_mutex = CreateMutexEx(NULL, NULL, 0, NULL);
79 m_mutex = CreateMutex(
84 if (m_mutex == NULL) {
85 std::cout <<
"CreateMutex error: " << GetLastError() << std::endl;
91 #if defined(VISP_HAVE_PTHREAD)
92 pthread_mutex_lock( &m_mutex );
96 dwWaitResult = WaitForSingleObjectEx(m_mutex, INFINITE, FALSE);
98 dwWaitResult = WaitForSingleObject(
102 if (dwWaitResult == WAIT_FAILED)
103 std::cout <<
"lock() error: " << GetLastError() << std::endl;
107 #if defined(VISP_HAVE_PTHREAD)
108 pthread_mutex_unlock( &m_mutex );
109 #elif defined(_WIN32)
111 if (!ReleaseMutex(m_mutex))
114 std::cout <<
"unlock() error: " << GetLastError() << std::endl;
190 #if defined(VISP_HAVE_PTHREAD)
191 pthread_mutex_t m_mutex;
192 #elif defined(_WIN32)
Class that allows protection by mutex.
~vpScopedLock()
Destructor that unlocks the mutex.
vpScopedLock(vpMutex &mutex)
Constructor that locks the mutex.