|
|
Boost.Threadslock_error |
The lock_error class defines an exception type that is thrown by lock operations that would deadlock or unlock operations performed by a thread that does not own the lock.
#include <boost/thread/thread.hpp>
class lock_error : public std::runtime_error
{
public:
lock_error();
};
lock_error();
Constructs a lock_error.
#include <boost/thread/mutex.hpp>
#include <boost/thread/thread.hpp>
#include <iostream>
int main(int, char*[])
{
boost::mutex mutex;
boost::mutex::lock lock(mutex);
try
{
boost::mutex::lock deadlock(mutex);
std::cout << "lock succeeded" << std::endl;
}
catch (boost::lock_error& err)
{
std::cout << err.what() << " - deadlock occurred." << std::endl;
}
}
The output is:
thread lock error - deadlock occurred.
Copyright William E. Kempf 2001 all rights reserved.