
Hello, I want to use timed lockable mutex in boost::thread, but the usage is not so obvious for a beginner. Would there be anywhere a sample code with this kind og mutex ? I have a code which works with a boost::mutex in a consumer/producer queue (code below). The purpose is to have a maximum waiting delay for waitForNotEmpty(). Thanks. ------------------------------------------------------------------------- template <typename T> class MTBornedQueue { public: .... bool waitForNotEmpty() { if (!m_container.empty()) return true; boost::mutex::scoped_lock lock(m_accessMutex); m_notEmpty.wait(lock, boost::bind(&MTBornedQueue<value_type>::isNotEmpty, this)); return true; } ... private: bool isNotEmpty() const { return m_unread > 0; }; size_type m_unread; container_type m_container; boost::mutex m_accessMutex; boost::condition m_notEmpty; }