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)
71 #if defined(VISP_HAVE_PTHREAD)
72 pthread_mutex_init(&m_mutex,
nullptr);
75 m_mutex = CreateMutexEx(
nullptr,
nullptr, 0,
nullptr);
77 m_mutex = CreateMutex(
nullptr,
81 if (m_mutex ==
nullptr) {
82 std::cout <<
"CreateMutex error: " << GetLastError() << std::endl;
89 #if defined(VISP_HAVE_PTHREAD)
90 pthread_mutex_lock(&m_mutex);
94 dwWaitResult = WaitForSingleObjectEx(m_mutex, INFINITE, FALSE);
96 dwWaitResult = WaitForSingleObject(m_mutex,
99 if (dwWaitResult == WAIT_FAILED)
100 std::cout <<
"lock() error: " << GetLastError() << std::endl;
105 #if defined(VISP_HAVE_PTHREAD)
106 pthread_mutex_unlock(&m_mutex);
107 #elif defined(_WIN32)
109 if (!ReleaseMutex(m_mutex)) {
111 std::cout <<
"unlock() error: " << GetLastError() << std::endl;
181 #if defined(VISP_HAVE_PTHREAD)
182 pthread_mutex_t m_mutex;
183 #elif defined(_WIN32)
Class that allows protection by mutex.
vpScopedLock(vpMutex &mutex)
Constructor that locks the mutex.
virtual ~vpScopedLock()
Destructor that unlocks the mutex.