<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>Glib::Mutex::Lock class Reference</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head> <body bgcolor="#ffffff"> <table border="0" width="100%"> <tr> <td width="10%" height="40"><img src="../../images/gtkmm_logo.gif" alt="logo" border="0" width="100%" height="100%"/></td> <td width="90%" height="40"><img src="../../images/top.gif" alt="top" width="100%" height="40"/></td> </tr> </table> <center> <a class="qindex" href="../../index.html">Main Page</a> <a href="group__Widgets.html">Widgets</a> <a class="qindex" href="namespaces.html"> Namespaces</a> <a href="../../tutorial/html/index.html"> Book</a> </center> <hr width="100%"/> <!-- Generated by Doxygen 1.3-rc1 --> <h1>Glib::Mutex::Lock Class Reference<br> <small> [<a class="el" href="group__Threads.html">Threads</a>]</small> </h1>Utility class for exception-safe mutex locking. <a href="#_details">More...</a> <p> <a href="classGlib_1_1Mutex_1_1Lock-members.html">List of all members.</a><table border=0 cellpadding=0 cellspacing=0> <tr><td></td></tr> <tr><td colspan=2><br><h2>Public Methods</h2></td></tr> <tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classGlib_1_1Mutex_1_1Lock.html#a0">Lock</a> (<a class="el" href="classGlib_1_1Mutex.html">Mutex</a>& mutex)</td></tr> <tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classGlib_1_1Mutex_1_1Lock.html#a1">Lock</a> (<a class="el" href="classGlib_1_1Mutex.html">Mutex</a>& mutex, <a class="el" href="group__Threads.html#a2">NotLock</a>)</td></tr> <tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classGlib_1_1Mutex_1_1Lock.html#a2">Lock</a> (<a class="el" href="classGlib_1_1Mutex.html">Mutex</a>& mutex, <a class="el" href="group__Threads.html#a3">TryLock</a>)</td></tr> <tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classGlib_1_1Mutex_1_1Lock.html#a3">~Lock</a> ()</td></tr> <tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classGlib_1_1Mutex_1_1Lock.html#a4">acquire</a> ()</td></tr> <tr><td nowrap align=right valign=top>bool </td><td valign=bottom><a class="el" href="classGlib_1_1Mutex_1_1Lock.html#a5">try_acquire</a> ()</td></tr> <tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classGlib_1_1Mutex_1_1Lock.html#a6">release</a> ()</td></tr> <tr><td nowrap align=right valign=top>bool </td><td valign=bottom><a class="el" href="classGlib_1_1Mutex_1_1Lock.html#a7">locked</a> () const</td></tr> </table> <hr><a name="_details"></a><h2>Detailed Description</h2> Utility class for exception-safe mutex locking. <p> <dl compact><dt><b>Usage example:</b></dt><dd><div class="fragment"><pre> { <a class="code" href="classGlib_1_1Mutex_1_1Lock.html">Glib::Mutex::Lock</a> <a class="code" href="classGlib_1_1Mutex.html#a2">lock</a> (mutex); <span class="comment">// calls mutex.lock()</span> do_something(); } <span class="comment">// the destructor calls mutex.unlock()</span> </pre></div>As you can see, the compiler takes care of the unlocking. This is not only exception safe but also much less error-prone. You could even <code>return</code> while still holding the lock and it will be released properly. </dd></dl> <dl compact><dt><b>Examples: </b></dt><dd> <p> <a class="el" href="thread_2thread_8cc-example.html#_a20">thread/thread.cc</a>.</dl> <p> <hr><h2>Constructor & Destructor Documentation</h2> <a name="a0" doxytag="Glib::Mutex::Lock::Lock"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> Glib::Mutex::Lock::Lock </td> <td class="md" valign="top">(</td> <td class="md" nowrap valign="top"><a class="el" href="classGlib_1_1Mutex.html">Mutex</a>& </td> <td class="mdname1" valign="top" nowrap> <em>mutex</em> </td> <td class="md" valign="top">) </td> <td class="md" nowrap><code> [inline, explicit]</code></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> </td> </tr> </table> <a name="a1" doxytag="Glib::Mutex::Lock::Lock"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> Glib::Mutex::Lock::Lock </td> <td class="md" valign="top">(</td> <td class="md" nowrap valign="top"><a class="el" href="classGlib_1_1Mutex.html">Mutex</a>& </td> <td class="mdname" nowrap> <em>mutex</em>, </td> </tr> <tr> <td></td> <td></td> <td class="md" nowrap><a class="el" href="group__Threads.html#a2">NotLock</a> </td> <td class="mdname" nowrap> </td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"><code> [inline]</code></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> </td> </tr> </table> <a name="a2" doxytag="Glib::Mutex::Lock::Lock"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> Glib::Mutex::Lock::Lock </td> <td class="md" valign="top">(</td> <td class="md" nowrap valign="top"><a class="el" href="classGlib_1_1Mutex.html">Mutex</a>& </td> <td class="mdname" nowrap> <em>mutex</em>, </td> </tr> <tr> <td></td> <td></td> <td class="md" nowrap><a class="el" href="group__Threads.html#a3">TryLock</a> </td> <td class="mdname" nowrap> </td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"><code> [inline]</code></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> </td> </tr> </table> <a name="a3" doxytag="Glib::Mutex::Lock::~Lock"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> Glib::Mutex::Lock::~Lock </td> <td class="md" valign="top">(</td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top">) </td> <td class="md" nowrap><code> [inline]</code></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> </td> </tr> </table> <hr><h2>Member Function Documentation</h2> <a name="a4" doxytag="Glib::Mutex::Lock::acquire"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> void Glib::Mutex::Lock::acquire </td> <td class="md" valign="top">(</td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top">) </td> <td class="md" nowrap><code> [inline]</code></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> </td> </tr> </table> <a name="a7" doxytag="Glib::Mutex::Lock::locked"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> bool Glib::Mutex::Lock::locked </td> <td class="md" valign="top">(</td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top">) </td> <td class="md" nowrap> const<code> [inline]</code></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> </td> </tr> </table> <a name="a6" doxytag="Glib::Mutex::Lock::release"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> void Glib::Mutex::Lock::release </td> <td class="md" valign="top">(</td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top">) </td> <td class="md" nowrap><code> [inline]</code></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> </td> </tr> </table> <a name="a5" doxytag="Glib::Mutex::Lock::try_acquire"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> bool Glib::Mutex::Lock::try_acquire </td> <td class="md" valign="top">(</td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top">) </td> <td class="md" nowrap><code> [inline]</code></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> </td> </tr> </table> <hr>The documentation for this class was generated from the following file:<ul> <li><a class="el" href="thread_8h.html">thread.h</a></ul> <hr><address><small> Generated for gtkmm by <a href="http://www.doxygen.org/index.html"> Doxygen</a> 1.3-rc1 © 1997-2001</small></address> </body> </html>