mirror of
https://github.com/boostorg/thread.git
synced 2026-01-22 05:42:37 +00:00
111 lines
3.1 KiB
HTML
111 lines
3.1 KiB
HTML
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content=
|
|
"text/html; charset=iso-8859-1">
|
|
<meta name="keywords" content="threads, BTL, thread library, C++">
|
|
<link rel="stylesheet" type="text/css" href="styles.css">
|
|
|
|
<title>Boost.Threads, lock_error</title>
|
|
</head>
|
|
|
|
<body bgcolor="#FFFFFF" link="#0000FF" vlink="#800080">
|
|
<table summary="header" border="0" cellpadding="7" cellspacing="0"
|
|
width="100%">
|
|
<tr>
|
|
<td valign="top" width="300">
|
|
<h3><img src="../../../c++boost.gif" alt="C++ Boost" width=
|
|
"277" height="86"></h3>
|
|
</td>
|
|
|
|
<td valign="top">
|
|
<h1 align="center">Boost.Threads</h1>
|
|
|
|
<h2 align="center">lock_error</h2>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<hr>
|
|
|
|
<p><a href="#Introduction">Introduction</a><br>
|
|
<a href="#Header">Header</a><br>
|
|
<a href="#Synopsis">Synopsis</a><br>
|
|
<a href="#Members">Members</a><br>
|
|
<a href="#Example">Example</a></p>
|
|
|
|
<h2><a name="Introduction">Introduction</a></h2>
|
|
|
|
<p>The <tt>lock_error</tt> class defines an exception type thrown to
|
|
indicate a locking related error has been detected. Examples of such
|
|
errors include a lock operation which can be determined to result in a
|
|
deadlock, or unlock operations attempted by a thread that does not own
|
|
the lock.</p>
|
|
|
|
<h2><a name="Header">Header</a></h2>
|
|
<pre>
|
|
#include <a href=
|
|
"../../../boost/thread/thread.hpp"><boost/thread/thread.hpp></a>
|
|
</pre>
|
|
|
|
<h2><a name="Synopsis">Synopsis</a></h2>
|
|
<pre>
|
|
namespace boost
|
|
|
|
class lock_error : public std::runtime_error
|
|
{
|
|
public:
|
|
lock_error();
|
|
};
|
|
}
|
|
</pre>
|
|
|
|
<h2><a name="Members">Members</a></h2>
|
|
<hr>
|
|
|
|
<h3>Constructor</h3>
|
|
<pre>
|
|
lock_error();
|
|
</pre>
|
|
|
|
<p>Constructs a <tt>lock_error</tt> object.</p>
|
|
<hr>
|
|
|
|
<h2><a name="Example">Example</a> Usage</h2>
|
|
<pre>
|
|
#include <a href=
|
|
"../../../boost/thread/mutex.hpp"><boost/thread/mutex.hpp></a>
|
|
#include <a href=
|
|
"../../../boost/thread/thread.hpp"><boost/thread/thread.hpp></a>
|
|
#include <iostream>
|
|
|
|
int main(int, char*[])
|
|
{
|
|
boost::mutex mutex;
|
|
boost::mutex::scoped_lock scoped_lock(mutex);
|
|
try
|
|
{
|
|
boost::mutex::scoped_lock deadlock(mutex);
|
|
std::cout << "lock succeeded" << std::endl;
|
|
}
|
|
catch (boost::lock_error& err)
|
|
{
|
|
std::cout << err.what() << " - deadlock occurred." << std::endl;
|
|
}
|
|
return 0;
|
|
}
|
|
</pre>
|
|
|
|
<p>The output is:</p>
|
|
<pre>
|
|
thread lock error - deadlock occurred.
|
|
</pre>
|
|
<hr>
|
|
|
|
<p>Revised
|
|
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->05 November, 2001<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
|
|
|
|
<p><i>© Copyright <a href="mailto:williamkempf@hotmail.com">
|
|
William E. Kempf</a> 2001 all rights reserved.</i></p>
|
|
</body>
|
|
</html>
|
|
|