/usr/share/doc/libjuce/apiref/classMessageManagerLock.html is in libjuce-doc 4.3.0~repack-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | <!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"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.12"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>JUCE: MessageManagerLock Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">JUCE
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.12 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
</div><!-- top -->
<div class="header">
<div class="summary">
<a href="#pub-methods">Public Member Functions</a> |
<a href="classMessageManagerLock-members.html">List of all members</a> </div>
<div class="headertitle">
<div class="title">MessageManagerLock Class Reference</div> </div>
</div><!--header-->
<div class="contents">
<p>Used to make sure that the calling thread has exclusive access to the message loop.
<a href="classMessageManagerLock.html#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a294fab36d4e9fe48cc2b52b36974111c"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classMessageManagerLock.html#a294fab36d4e9fe48cc2b52b36974111c">MessageManagerLock</a> (<a class="el" href="classThread.html">Thread</a> *threadToCheckForExitSignal=nullptr)</td></tr>
<tr class="memdesc:a294fab36d4e9fe48cc2b52b36974111c"><td class="mdescLeft"> </td><td class="mdescRight">Tries to acquire a lock on the message manager. <a href="#a294fab36d4e9fe48cc2b52b36974111c">More...</a><br /></td></tr>
<tr class="separator:a294fab36d4e9fe48cc2b52b36974111c"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ac6da971e61e376e8216da1f39ccb5582"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classMessageManagerLock.html#ac6da971e61e376e8216da1f39ccb5582">MessageManagerLock</a> (<a class="el" href="classThreadPoolJob.html">ThreadPoolJob</a> *jobToCheckForExitSignal)</td></tr>
<tr class="memdesc:ac6da971e61e376e8216da1f39ccb5582"><td class="mdescLeft"> </td><td class="mdescRight">This has the same behaviour as the other constructor, but takes a <a class="el" href="classThreadPoolJob.html" title="A task that is executed by a ThreadPool object. ">ThreadPoolJob</a> instead of a thread. <a href="#ac6da971e61e376e8216da1f39ccb5582">More...</a><br /></td></tr>
<tr class="separator:ac6da971e61e376e8216da1f39ccb5582"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a4d3e1ab142b50ad49e5fe60f8ae7d22f"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classMessageManagerLock.html#a4d3e1ab142b50ad49e5fe60f8ae7d22f">~MessageManagerLock</a> () noexcept</td></tr>
<tr class="memdesc:a4d3e1ab142b50ad49e5fe60f8ae7d22f"><td class="mdescLeft"> </td><td class="mdescRight">Releases the current thread's lock on the message manager. <a href="#a4d3e1ab142b50ad49e5fe60f8ae7d22f">More...</a><br /></td></tr>
<tr class="separator:a4d3e1ab142b50ad49e5fe60f8ae7d22f"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a5f3d8b6abc27aa324a882abc6e2d96ba"><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classMessageManagerLock.html#a5f3d8b6abc27aa324a882abc6e2d96ba">lockWasGained</a> () const noexcept</td></tr>
<tr class="memdesc:a5f3d8b6abc27aa324a882abc6e2d96ba"><td class="mdescLeft"> </td><td class="mdescRight">Returns true if the lock was successfully acquired. <a href="#a5f3d8b6abc27aa324a882abc6e2d96ba">More...</a><br /></td></tr>
<tr class="separator:a5f3d8b6abc27aa324a882abc6e2d96ba"><td class="memSeparator" colspan="2"> </td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Used to make sure that the calling thread has exclusive access to the message loop. </p>
<p>Because it's not thread-safe to call any of the <a class="el" href="classComponent.html" title="The base class for all JUCE user-interface objects. ">Component</a> or other UI classes from threads other than the message thread, one of these objects can be used to lock the message loop and allow this to be done. The message thread will be suspended for the lifetime of the <a class="el" href="classMessageManagerLock.html" title="Used to make sure that the calling thread has exclusive access to the message loop. ">MessageManagerLock</a> object, so create one on the stack like this:</p><div class="fragment"><div class="line"><span class="keywordtype">void</span> MyThread::run()</div><div class="line">{</div><div class="line"> someData = 1234;</div><div class="line"></div><div class="line"> <span class="keyword">const</span> <a class="code" href="classMessageManagerLock.html">MessageManagerLock</a> mmLock;</div><div class="line"> <span class="comment">// the event loop will now be locked so it's safe to make a few calls..</span></div><div class="line"></div><div class="line"> myComponent->setBounds (newBounds);</div><div class="line"> myComponent->repaint();</div><div class="line"></div><div class="line"> <span class="comment">// ..the event loop will now be unlocked as the MessageManagerLock goes out of scope</span></div><div class="line">}</div></div><!-- fragment --><p>Obviously be careful not to create one of these and leave it lying around, or your app will grind to a halt!</p>
<p>MessageManagerLocks are re-entrant, so can be safely nested if the current thread already has the lock.</p>
<p>Another caveat is that using this in conjunction with other CriticalSections can create lots of interesting ways of producing a deadlock! In particular, if your message thread calls stopThread() for a thread that uses these locks, you'll get an (occasional) deadlock..</p>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="classMessageManager.html" title="This class is in charge of the application's event-dispatch loop. ">MessageManager</a>, <a class="el" href="classMessageManager.html#aebd4b8896d7b6bdfa34d3cd8eb2e1777" title="Returns true if the caller thread has currently got the message manager locked. ">MessageManager::currentThreadHasLockedMessageManager</a> </dd></dl>
</div><h2 class="groupheader">Constructor & Destructor Documentation</h2>
<a id="a294fab36d4e9fe48cc2b52b36974111c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a294fab36d4e9fe48cc2b52b36974111c">§ </a></span>MessageManagerLock() <span class="overload">[1/2]</span></h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">MessageManagerLock::MessageManagerLock </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classThread.html">Thread</a> * </td>
<td class="paramname"><em>threadToCheckForExitSignal</em> = <code>nullptr</code></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Tries to acquire a lock on the message manager. </p>
<p>The constructor attempts to gain a lock on the message loop, and the lock will be kept for the lifetime of this object.</p>
<p>Optionally, you can pass a thread object here, and while waiting to obtain the lock, this method will keep checking whether the thread has been given the <a class="el" href="classThread.html#affe168e27c6ee50b0d10522810772268" title="Sets a flag to tell the thread it should stop. ">Thread::signalThreadShouldExit()</a> signal. If this happens, then it will return without gaining the lock. If you pass a thread, you must check whether the lock was successful by calling <a class="el" href="classMessageManagerLock.html#a5f3d8b6abc27aa324a882abc6e2d96ba" title="Returns true if the lock was successfully acquired. ">lockWasGained()</a>. If this is false, your thread is being told to die, so you should take evasive action.</p>
<p>If you pass nullptr for the thread object, it will wait indefinitely for the lock - be careful when doing this, because it's very easy to deadlock if your message thread attempts to call stopThread() on a thread just as that thread attempts to get the message lock.</p>
<p>If the calling thread already has the lock, nothing will be done, so it's safe and quick to use these locks recursively.</p>
<p>E.g. </p><div class="fragment"><div class="line"><span class="keywordtype">void</span> run()</div><div class="line">{</div><div class="line"> ...</div><div class="line"></div><div class="line"> <span class="keywordflow">while</span> (! threadShouldExit())</div><div class="line"> {</div><div class="line"> <a class="code" href="classMessageManagerLock.html">MessageManagerLock</a> mml (<a class="code" href="classThread.html#a40a9f45ea3ff9a7d39a50f78059640cd">Thread::getCurrentThread</a>());</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (! mml.lockWasGained())</div><div class="line"> <span class="keywordflow">return</span>; <span class="comment">// another thread is trying to kill us!</span></div><div class="line"></div><div class="line"> ..<span class="keywordflow">do</span> some locked stuff here..</div><div class="line"> }</div><div class="line"></div><div class="line"> ..and now the MM is now unlocked..</div><div class="line">}</div></div><!-- fragment -->
</div>
</div>
<a id="ac6da971e61e376e8216da1f39ccb5582"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac6da971e61e376e8216da1f39ccb5582">§ </a></span>MessageManagerLock() <span class="overload">[2/2]</span></h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">MessageManagerLock::MessageManagerLock </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classThreadPoolJob.html">ThreadPoolJob</a> * </td>
<td class="paramname"><em>jobToCheckForExitSignal</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>This has the same behaviour as the other constructor, but takes a <a class="el" href="classThreadPoolJob.html" title="A task that is executed by a ThreadPool object. ">ThreadPoolJob</a> instead of a thread. </p>
<p>See the <a class="el" href="classMessageManagerLock.html" title="Used to make sure that the calling thread has exclusive access to the message loop. ">MessageManagerLock</a> (Thread*) constructor for details on how this works. </p>
</div>
</div>
<a id="a4d3e1ab142b50ad49e5fe60f8ae7d22f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4d3e1ab142b50ad49e5fe60f8ae7d22f">§ </a></span>~MessageManagerLock()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">MessageManagerLock::~MessageManagerLock </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Releases the current thread's lock on the message manager. </p>
<p>Make sure this object is created and deleted by the same thread, otherwise there are no guarantees what will happen! </p>
</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="a5f3d8b6abc27aa324a882abc6e2d96ba"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5f3d8b6abc27aa324a882abc6e2d96ba">§ </a></span>lockWasGained()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">bool MessageManagerLock::lockWasGained </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td> const</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Returns true if the lock was successfully acquired. </p>
<p>(See the constructor that takes a <a class="el" href="classThread.html" title="Encapsulates a thread. ">Thread</a> for more info). </p>
</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="juce__MessageManager_8h.html">juce_MessageManager.h</a></li>
</ul>
</div><!-- contents -->
<hr class="footer"/>
<address class="footer"><small>All content © ROLI Ltd.</small></address><br/>
</body>
</html>
|