27 #include <boost/thread/condition_variable.hpp>
28 #include <boost/thread/locks.hpp>
29 #include <boost/thread/mutex.hpp>
30 #include <boost/thread/recursive_mutex.hpp>
31 #include <boost/thread/shared_mutex.hpp>
35 #define MUTEX_TIMEOUT_MSEC 10000
48 std::stringstream reason;
49 reason <<
"A Thread failed to get a mutex '" + mutexName +
"' after "
50 << timeoutDelayMs * 0.001 <<
" seconds!";
51 setReason(reason.str());
57 return "armarx::exceptions::local::MutexTimeoutException";
64 LocalException(
"A mutex '" + mutexName +
65 "' was not already unlocked in the destructor!")
72 return "armarx::exceptions::local::MutexDestructionException";
90 boost::timed_mutex timedMutex;
92 std::string mutexName;
96 timeoutDelayMs(timeout), mutexName(mutexName)
105 std::cout <<
"A mutex ('" << mutexName
106 <<
"') was still locked in the destructor! Fix Application!\nBacktrace:\n"
107 << LocalException::generateBacktrace() << std::endl;
118 boost::system_time timeout =
119 boost::get_system_time() + boost::posix_time::milliseconds(timeoutDelayMs);
121 if (!timedMutex.timed_lock(timeout))
130 return timedMutex.try_lock();