1
<?xml version="1.0" encoding="iso-8859-1"?>
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
3
<html><head><title>QWriteLocker Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
4
a:link { color: #004faf; text-decoration: none }
5
a:visited { color: #672967; text-decoration: none }
6
td.postheader { font-family: sans-serif }
7
tr.address { font-family: sans-serif }
8
body { background: #ffffff; color: black; }
9
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QWriteLocker Class Reference<br /><sup><sup>[<a href="qtcore.html">QtCore</a> module]</sup></sup></h1><p>The QWriteLocker class is a convenience class that simplifies
10
locking and unlocking read-write locks for write access. <a href="#details">More...</a></p>
12
<h3>Methods</h3><ul><li><div class="fn" /><b><a href="qwritelocker.html#QWriteLocker">__init__</a></b> (<i>self</i>, QReadWriteLock <i>areadWriteLock</i>)</li><li><div class="fn" />QReadWriteLock <b><a href="qwritelocker.html#readWriteLock">readWriteLock</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qwritelocker.html#relock">relock</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qwritelocker.html#unlock">unlock</a></b> (<i>self</i>)</li></ul><h3>Special Methods</h3><ul><li><div class="fn" />object <b><a href="qwritelocker.html#__enter__">__enter__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qwritelocker.html#__exit__">__exit__</a></b> (<i>self</i>, object <i>type</i>, object <i>value</i>, object <i>traceback</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QWriteLocker class is a convenience class that simplifies
13
locking and unlocking read-write locks for write access.</p>
14
<p>The purpose of QWriteLocker (and <a href="qreadlocker.html">QReadLocker</a> is to simplify <a href="qreadwritelock.html">QReadWriteLock</a> locking and unlocking.
15
Locking and unlocking statements or in exception handling code is
16
error-prone and difficult to debug. QWriteLocker can be used in
17
such situations to ensure that the state of the lock is always
19
<p>Here's an example that uses QWriteLocker to lock and unlock a
20
read-write lock for writing:</p>
22
<span class="type"><a href="qreadwritelock.html">QReadWriteLock</a></span> lock;
24
<span class="type">void</span> writeData(<span class="keyword">const</span> <span class="type"><a href="qbytearray.html">QByteArray</a></span> <span class="operator">&</span>data)
26
<span class="type">QWriteLocker</span> locker(<span class="operator">&</span>lock);
27
<span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
30
<p>It is equivalent to the following code:</p>
32
<span class="type"><a href="qreadwritelock.html">QReadWriteLock</a></span> lock;
34
<span class="type">void</span> writeData(<span class="keyword">const</span> <span class="type"><a href="qbytearray.html">QByteArray</a></span> <span class="operator">&</span>data)
36
lock<span class="operator">.</span>lockForWrite();
37
<span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
38
lock<span class="operator">.</span>unlock();
41
<p>The <a href="qmutexlocker.html">QMutexLocker</a> documentation
42
shows examples where the use of a locker object greatly simplifies
44
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QWriteLocker" />QWriteLocker.__init__ (<i>self</i>, <a href="qreadwritelock.html">QReadWriteLock</a> <i>areadWriteLock</i>)</h3><p>Constructs a <a href="qwritelocker.html">QWriteLocker</a> and
45
locks <i>lock</i> for writing. The lock will be unlocked when the
46
<a href="qwritelocker.html">QWriteLocker</a> is destroyed. If
47
<tt>lock</tt> is zero, <a href="qwritelocker.html">QWriteLocker</a>
49
<p><b>See also</b> <a href="qreadwritelock.html#lockForWrite">QReadWriteLock.lockForWrite</a>().</p>
52
<h3 class="fn"><a name="readWriteLock" /><a href="qreadwritelock.html">QReadWriteLock</a> QWriteLocker.readWriteLock (<i>self</i>)</h3><p>Returns a pointer to the read-write lock that was passed to the
56
<h3 class="fn"><a name="relock" />QWriteLocker.relock (<i>self</i>)</h3><p>Relocks an unlocked lock.</p>
57
<p><b>See also</b> <a href="qwritelocker.html#unlock">unlock</a>().</p>
60
<h3 class="fn"><a name="unlock" />QWriteLocker.unlock (<i>self</i>)</h3><p>Unlocks the lock associated with this locker.</p>
61
<p><b>See also</b> <a href="qreadwritelock.html#unlock">QReadWriteLock.unlock</a>().</p>
62
<h3 class="fn"><a name="__enter__" />object QWriteLocker.__enter__ (<i>self</i>)</h3><h3 class="fn"><a name="__exit__" />QWriteLocker.__exit__ (<i>self</i>, object <i>type</i>, object <i>value</i>, object <i>traceback</i>)</h3><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.10.3 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt 4.8.5</td></tr></table></div></address></body></html>
b'\\ No newline at end of file'