diff options
| author | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
| commit | 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch) | |
| tree | f1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/gcc~13/synchronization.html | |
new repository
Diffstat (limited to 'devdocs/gcc~13/synchronization.html')
| -rw-r--r-- | devdocs/gcc~13/synchronization.html | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/devdocs/gcc~13/synchronization.html b/devdocs/gcc~13/synchronization.html new file mode 100644 index 00000000..750d7215 --- /dev/null +++ b/devdocs/gcc~13/synchronization.html @@ -0,0 +1,9 @@ +<div class="section-level-extent" id="Synchronization"> <div class="nav-panel"> <p> Next: <a href="fast-enumeration" accesskey="n" rel="next">Fast Enumeration</a>, Previous: <a href="exceptions" accesskey="p" rel="prev">Exceptions</a>, Up: <a href="objective-c" accesskey="u" rel="up">GNU Objective-C Features</a> [<a href="index#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="indices" title="Index" rel="index">Index</a>]</p> </div> <h1 class="section" id="Synchronization-1"><span>8.8 Synchronization<a class="copiable-link" href="#Synchronization-1"> ¶</a></span></h1> <p>GNU Objective-C provides support for synchronized blocks: </p> <div class="example smallexample"> <pre class="example-preformatted" data-language="cpp">@synchronized (ObjCClass *guard) { + … +}</pre> +</div> <p>Upon entering the <code class="code">@synchronized</code> block, a thread of execution shall first check whether a lock has been placed on the corresponding <code class="code">guard</code> object by another thread. If it has, the current thread shall wait until the other thread relinquishes its lock. Once <code class="code">guard</code> becomes available, the current thread will place its own lock on it, execute the code contained in the <code class="code">@synchronized</code> block, and finally relinquish the lock (thereby making <code class="code">guard</code> available to other threads). </p> <p>Unlike Java, Objective-C does not allow for entire methods to be marked <code class="code">@synchronized</code>. Note that throwing exceptions out of <code class="code">@synchronized</code> blocks is allowed, and will cause the guarding object to be unlocked properly. </p> <p>Because of the interactions between synchronization and exception handling, you can only use <code class="code">@synchronized</code> when compiling with exceptions enabled, that is with the command line option <samp class="option">-fobjc-exceptions</samp>. </p> </div><div class="_attribution"> + <p class="_attribution-p"> + © Free Software Foundation<br>Licensed under the GNU Free Documentation License, Version 1.3.<br> + <a href="https://gcc.gnu.org/onlinedocs/gcc-13.1.0/gcc/Synchronization.html" class="_attribution-link">https://gcc.gnu.org/onlinedocs/gcc-13.1.0/gcc/Synchronization.html</a> + </p> +</div> |
