38 #include <visp3/core/vpConfig.h>
40 #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) && (defined(VISP_HAVE_PTHREAD) || (defined(_WIN32) && !defined(WINRT_8_0)))
42 #if defined(VISP_HAVE_PTHREAD)
51 #ifdef ENABLE_VISP_NAMESPACE
75 #if defined(VISP_HAVE_PTHREAD)
76 pthread_mutex_init(&m_mutex,
nullptr);
79 m_mutex = CreateMutexEx(
nullptr,
nullptr, 0,
nullptr);
81 m_mutex = CreateMutex(
nullptr,
85 if (m_mutex ==
nullptr) {
86 std::cout <<
"CreateMutex error: " << GetLastError() << std::endl;
93 #if defined(VISP_HAVE_PTHREAD)
94 pthread_mutex_lock(&m_mutex);
98 dwWaitResult = WaitForSingleObjectEx(m_mutex, INFINITE, FALSE);
100 dwWaitResult = WaitForSingleObject(m_mutex,
103 if (dwWaitResult == WAIT_FAILED)
104 std::cout <<
"lock() error: " << GetLastError() << std::endl;
109 #if defined(VISP_HAVE_PTHREAD)
110 pthread_mutex_unlock(&m_mutex);
111 #elif defined(_WIN32)
113 if (!ReleaseMutex(m_mutex)) {
115 std::cout <<
"unlock() error: " << GetLastError() << std::endl;
193 #if defined(VISP_HAVE_PTHREAD)
194 pthread_mutex_t m_mutex;
195 #elif defined(_WIN32)
199 #ifdef ENABLE_VISP_NAMESPACE
Class that allows protection by mutex.
vpScopedLock(vpMutex &mutex)
Constructor that locks the mutex.
virtual ~vpScopedLock()
Destructor that unlocks the mutex.