<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>glibmm: Glib::Mutex Class Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.6.1 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li class="current"><a href="annotated.html"><span>Classes</span></a></li> <li><a href="examples.html"><span>Examples</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="annotated.html"><span>Class List</span></a></li> <li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li> <li><a href="functions.html"><span>Class Members</span></a></li> </ul> </div> <div class="navpath"><a class="el" href="namespaceGlib.html">Glib</a>::<a class="el" href="classGlib_1_1Mutex.html">Mutex</a> </div> </div> <div class="contents"> <h1>Glib::Mutex Class Reference<br/> <small> [<a class="el" href="group__Threads.html">Threads</a>]</small> </h1><!-- doxytag: class="Glib::Mutex" --> <p>Represents a mutex (mutual exclusion). <a href="#_details">More...</a></p> <p><a href="classGlib_1_1Mutex-members.html">List of all members.</a></p> <table border="0" cellpadding="0" cellspacing="0"> <tr><td colspan="2"><h2>Classes</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1Mutex_1_1Lock.html">Lock</a></td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Utility class for exception-safe mutex locking. <a href="classGlib_1_1Mutex_1_1Lock.html#_details">More...</a><br/></td></tr> <tr><td colspan="2"><h2>Public Member Functions</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1Mutex.html#a0e529e72691cbab324f7c70110d95031">Mutex</a> ()</td></tr> <tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1Mutex.html#ac1a701f93ad62d97f9c34e98b6b3f7be">~Mutex</a> ()</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1Mutex.html#abd565d2c03dbd7526729b8e56ecc675e">lock</a> ()</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Locks the mutex. <a href="#abd565d2c03dbd7526729b8e56ecc675e"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1Mutex.html#aa564c753a2e51994c3faee2b1d8c903c">trylock</a> ()</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Tries to lock the mutex. <a href="#aa564c753a2e51994c3faee2b1d8c903c"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1Mutex.html#a254d550a0e2197d46fa7268475f19824">unlock</a> ()</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Unlocks the mutex. <a href="#a254d550a0e2197d46fa7268475f19824"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">GMutex* </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1Mutex.html#affe6aea5c5044a51422dd08f2dc06d98">gobj</a> ()</td></tr> </table> <hr/><a name="_details"></a><h2>Detailed Description</h2> <p>Represents a mutex (mutual exclusion). </p> <p>It can be used to protect data against shared access. Try to use <a class="el" href="classGlib_1_1Mutex_1_1Lock.html" title="Utility class for exception-safe mutex locking.">Mutex::Lock</a> instead of calling <a class="el" href="classGlib_1_1Mutex.html#abd565d2c03dbd7526729b8e56ecc675e" title="Locks the mutex.">lock()</a> and <a class="el" href="classGlib_1_1Mutex.html#a254d550a0e2197d46fa7268475f19824" title="Unlocks the mutex.">unlock()</a> directly -- it will make your life much easier.</p> <dl class="note"><dt><b>Note:</b></dt><dd>Before creating a <a class="el" href="classGlib_1_1Mutex.html" title="Represents a mutex (mutual exclusion).">Glib::Mutex</a>, <a class="el" href="group__Threads.html#gab26d01c776801f1fff00753e97af4fc7" title="Initializes the GLib thread system.">Glib::thread_init()</a> has to be called.</dd> <dd> <a class="el" href="classGlib_1_1Mutex.html" title="Represents a mutex (mutual exclusion).">Glib::Mutex</a> is not recursive, i.e. a thread will deadlock, if it already has locked the mutex while calling <a class="el" href="classGlib_1_1Mutex.html#abd565d2c03dbd7526729b8e56ecc675e" title="Locks the mutex.">lock()</a>. Use <a class="el" href="classGlib_1_1RecMutex.html">Glib::RecMutex</a> instead, if you need recursive mutexes. </dd></dl> <dl><dt><b>Examples: </b></dt><dd> <p><a class="el" href="thread_2thread_8cc-example.html#_a1">thread/thread.cc</a>.</p> </dd> </dl><hr/><h2>Constructor & Destructor Documentation</h2> <a class="anchor" id="a0e529e72691cbab324f7c70110d95031"></a><!-- doxytag: member="Glib::Mutex::Mutex" ref="a0e529e72691cbab324f7c70110d95031" args="()" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">Glib::Mutex::Mutex </td> <td>(</td> <td class="paramname"></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> </div> </div> <a class="anchor" id="ac1a701f93ad62d97f9c34e98b6b3f7be"></a><!-- doxytag: member="Glib::Mutex::~Mutex" ref="ac1a701f93ad62d97f9c34e98b6b3f7be" args="()" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">Glib::Mutex::~Mutex </td> <td>(</td> <td class="paramname"></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> </div> </div> <hr/><h2>Member Function Documentation</h2> <a class="anchor" id="affe6aea5c5044a51422dd08f2dc06d98"></a><!-- doxytag: member="Glib::Mutex::gobj" ref="affe6aea5c5044a51422dd08f2dc06d98" args="()" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">GMutex* Glib::Mutex::gobj </td> <td>(</td> <td class="paramname"></td> <td> ) </td> <td><code> [inline]</code></td> </tr> </table> </div> <div class="memdoc"> </div> </div> <a class="anchor" id="abd565d2c03dbd7526729b8e56ecc675e"></a><!-- doxytag: member="Glib::Mutex::lock" ref="abd565d2c03dbd7526729b8e56ecc675e" args="()" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void Glib::Mutex::lock </td> <td>(</td> <td class="paramname"></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Locks the mutex. </p> <p>If mutex is already locked by another thread, the current thread will block until mutex is unlocked by the other thread. </p> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="classGlib_1_1Mutex_1_1Lock.html" title="Utility class for exception-safe mutex locking.">Mutex::Lock</a> </dd></dl> </div> </div> <a class="anchor" id="aa564c753a2e51994c3faee2b1d8c903c"></a><!-- doxytag: member="Glib::Mutex::trylock" ref="aa564c753a2e51994c3faee2b1d8c903c" args="()" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">bool Glib::Mutex::trylock </td> <td>(</td> <td class="paramname"></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Tries to lock the mutex. </p> <p>If the mutex is already locked by another thread, it immediately returns <code>false</code>. Otherwise it locks the mutex and returns <code>true</code>. </p> <dl class="return"><dt><b>Returns:</b></dt><dd>Whether the mutex could be locked. </dd></dl> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="classGlib_1_1Mutex_1_1Lock.html" title="Utility class for exception-safe mutex locking.">Mutex::Lock</a> </dd></dl> </div> </div> <a class="anchor" id="a254d550a0e2197d46fa7268475f19824"></a><!-- doxytag: member="Glib::Mutex::unlock" ref="a254d550a0e2197d46fa7268475f19824" args="()" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void Glib::Mutex::unlock </td> <td>(</td> <td class="paramname"></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Unlocks the mutex. </p> <p>If another thread is blocked in a <a class="el" href="classGlib_1_1Mutex.html#abd565d2c03dbd7526729b8e56ecc675e" title="Locks the mutex.">lock()</a> call for this mutex, it will be woken and can lock the mutex itself. </p> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="classGlib_1_1Mutex_1_1Lock.html" title="Utility class for exception-safe mutex locking.">Mutex::Lock</a> </dd></dl> </div> </div> <hr/>The documentation for this class was generated from the following file:<ul> <li>glibmm/thread.h</li> </ul> </div> <hr size="1"/><address style="text-align: right;"><small>Generated on Mon Sep 21 11:07:25 2009 for glibmm by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> </body> </html>