~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to doc/html/qwritelocker.html

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="iso-8859-1"?>
 
2
<!DOCTYPE html
 
3
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
 
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
5
<!-- /tmp/qt-4.0.0-espenr-1119621036935/qt-x11-opensource-desktop-4.0.0/src/corelib/thread/qreadwritelock_unix.cpp -->
 
6
<head>
 
7
    <title>Qt 4.0: QWriteLocker Class Reference</title>
 
8
    <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
 
9
a:link { color: #004faf; text-decoration: none }
 
10
a:visited { color: #672967; text-decoration: none }
 
11
td.postheader { font-family: sans-serif }
 
12
tr.address { font-family: sans-serif }
 
13
body { background: #ffffff; color: black; }</style>
 
14
</head>
 
15
<body>
 
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
 
17
<tr>
 
18
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
 
19
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="annotated.html"><font color="#004faf">Annotated</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
 
20
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">QWriteLocker Class Reference</h1>
 
21
<p>The QWriteLocker class is a convenience class that simplifies locking and unlocking read-write locks for write access. <a href="#details">More...</a></p>
 
22
<pre>#include &lt;QWriteLocker&gt;</pre><p>Part of the <a href="qtcore.html">QtCore</a> module.</p>
 
23
<p><b>Note:</b> All the functions in this class are <a href="threads.html#thread-safe">thread-safe</a>.</p>
 
24
<ul>
 
25
<li><a href="qwritelocker-members.html">List of all members, including inherited members</a></li>
 
26
</ul>
 
27
<a name="public-functions"></a>
 
28
<h3>Public Functions</h3>
 
29
<ul>
 
30
<li><div class="fn"/><b><a href="qwritelocker.html#QWriteLocker">QWriteLocker</a></b> ( QReadWriteLock * <i>lock</i> )</li>
 
31
<li><div class="fn"/><b><a href="qwritelocker.html#dtor.QWriteLocker">~QWriteLocker</a></b> ()</li>
 
32
<li><div class="fn"/>QReadWriteLock * <b><a href="qwritelocker.html#readWriteLock">readWriteLock</a></b> () const</li>
 
33
<li><div class="fn"/>void <b><a href="qwritelocker.html#relock">relock</a></b> ()</li>
 
34
<li><div class="fn"/>void <b><a href="qwritelocker.html#unlock">unlock</a></b> ()</li>
 
35
</ul>
 
36
<a name="details"></a>
 
37
<hr />
 
38
<h2>Detailed Description</h2>
 
39
<p>The QWriteLocker class is a convenience class that simplifies locking and unlocking read-write locks for write access.</p>
 
40
<p>The purpose of QWriteLocker (and <a href="qreadlocker.html">QReadLocker</a> is to simplify <a href="qreadwritelock.html">QReadWriteLock</a> locking and unlocking. Locking and unlocking statements or in exception handling code is error-prone and difficult to debug. QWriteLocker can be used in such situations to ensure that the state of the lock is always well-defined.</p>
 
41
<p>Here's an example that uses QWriteLocker to lock and unlock a read-write lock for writing:</p>
 
42
<pre>&nbsp;   QReadWriteLock lock;
 
43
 
 
44
    void writeData(const QByteArray &amp;data)
 
45
    {
 
46
        QWriteLocker locker(&amp;lock);
 
47
        ...
 
48
    }</pre>
 
49
<p>It is equivalent to the following code:</p>
 
50
<pre>&nbsp;   QReadWriteLock lock;
 
51
 
 
52
    void writeData(const QByteArray &amp;data)
 
53
    {
 
54
        locker.lockForWrite();
 
55
        ...
 
56
        locker.unlock();
 
57
    }</pre>
 
58
<p>The <a href="qmutexlocker.html">QMutexLocker</a> documentation shows examples where the use of a locker object greatly simplifies programming.</p>
 
59
<p>See also <a href="qreadlocker.html">QReadLocker</a> and <a href="qreadwritelock.html">QReadWriteLock</a>.</p>
 
60
<hr />
 
61
<h2>Member Function Documentation</h2>
 
62
<h3 class="fn"><a name="QWriteLocker"></a>QWriteLocker::QWriteLocker ( <a href="qreadwritelock.html">QReadWriteLock</a> * <i>lock</i> )</h3>
 
63
<p>Constructs a <a href="qwritelocker.html">QWriteLocker</a> and locks <i>lock</i> for writing. The lock will be unlocked when the <a href="qwritelocker.html">QWriteLocker</a> is destroyed. If <tt>lock</tt> is zero, <a href="qwritelocker.html">QWriteLocker</a> does nothing.</p>
 
64
<p>See also <a href="qreadwritelock.html#lockForWrite">QReadWriteLock::lockForWrite</a>().</p>
 
65
<h3 class="fn"><a name="dtor.QWriteLocker"></a>QWriteLocker::~QWriteLocker ()</h3>
 
66
<p>Destroys the <a href="qwritelocker.html">QWriteLocker</a> and unlocks the lock that was passed to the constructor.</p>
 
67
<p>See also <a href="qreadwritelock.html#unlock">QReadWriteLock::unlock</a>().</p>
 
68
<h3 class="fn"><a name="readWriteLock"></a><a href="qreadwritelock.html">QReadWriteLock</a> * QWriteLocker::readWriteLock () const</h3>
 
69
<p>Returns a pointer to the read-write lock that was passed to the constructor.</p>
 
70
<h3 class="fn"><a name="relock"></a>void QWriteLocker::relock ()</h3>
 
71
<p>Relocks an unlocked lock.</p>
 
72
<p>See also <a href="qwritelocker.html#unlock">unlock</a>().</p>
 
73
<h3 class="fn"><a name="unlock"></a>void QWriteLocker::unlock ()</h3>
 
74
<p>Unlocks the lock associated with this locker.</p>
 
75
<p>See also <a href="qreadwritelock.html#unlock">QReadWriteLock::unlock</a>().</p>
 
76
<p /><address><hr /><div align="center">
 
77
<table width="100%" cellspacing="0" border="0"><tr class="address">
 
78
<td width="30%">Copyright &copy; 2005 <a href="trolltech.html">Trolltech</a></td>
 
79
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
 
80
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
 
81
</tr></table></div></address></body>
 
82
</html>