diff options
| author | Craig Jennings <c@cjennings.net> | 2025-08-14 22:58:58 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2025-08-14 22:58:58 -0500 |
| commit | 82ba818ff456bcd6d56a06226e3f27e98fbb55c3 (patch) | |
| tree | 158cfc17b2f644a10f063cb546752cfaae12c97f /devdocs/c/thread%2Fcall_once.html | |
| parent | 9278ddd4ea1a8b1a4c1edaa8894516e3f48d245b (diff) | |
| download | dotemacs-82ba818ff456bcd6d56a06226e3f27e98fbb55c3.tar.gz dotemacs-82ba818ff456bcd6d56a06226e3f27e98fbb55c3.zip | |
removing all downloaded devdocs files
Diffstat (limited to 'devdocs/c/thread%2Fcall_once.html')
| -rw-r--r-- | devdocs/c/thread%2Fcall_once.html | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/devdocs/c/thread%2Fcall_once.html b/devdocs/c/thread%2Fcall_once.html deleted file mode 100644 index c49a1c35..00000000 --- a/devdocs/c/thread%2Fcall_once.html +++ /dev/null @@ -1,55 +0,0 @@ - <h1 id="firstHeading" class="firstHeading">call_once, once_flag, ONCE_FLAG_INIT</h1> <table class="t-dcl-begin"> <tr class="t-dsc-header"> <th> Defined in header <code><threads.h></code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl t-since-c11"> <td> <pre data-language="c">void call_once( once_flag* flag, void (*func)(void) );</pre> -</td> <td> (1) </td> <td> <span class="t-mark-rev t-since-c11">(since C11)</span> </td> </tr> <tr class="t-dcl t-since-c11"> <td> <pre data-language="c">typedef /* unspecified */ once_flag</pre> -</td> <td> (2) </td> <td> <span class="t-mark-rev t-since-c11">(since C11)</span> </td> </tr> <tr class="t-dcl t-since-c11"> <td> <pre data-language="c">#define ONCE_FLAG_INIT /* unspecified */</pre> -</td> <td> (3) </td> <td> <span class="t-mark-rev t-since-c11">(since C11)</span> </td> </tr> </table> <div class="t-li1"> -<span class="t-li">1)</span> Calls function <code>func</code> exactly once, even if invoked from several threads. The completion of the function <code>func</code> synchronizes with all previous or subsequent calls to <code>call_once</code> with the same <code>flag</code> variable.</div> <div class="t-li1"> -<span class="t-li">2)</span> Complete object type capable of holding a flag used by <code>call_once</code>.</div> <div class="t-li1"> -<span class="t-li">3)</span> Expands to a value that can be used to initialize an object of type <code>once_flag</code>.</div> <h3 id="Parameters"> Parameters</h3> <table class="t-par-begin"> <tr class="t-par"> <td> flag </td> <td> - </td> <td> pointer to an object of type <code>call_once</code> that is used to ensure <code>func</code> is called only once </td> -</tr> <tr class="t-par"> <td> func </td> <td> - </td> <td> the function to execute only once </td> -</tr> -</table> <h3 id="Return_value"> Return value</h3> <p>(none)</p> -<h3 id="Notes"> Notes</h3> <p>The POSIX equivalent of this function is <a rel="nofollow" class="external text" href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_once.html"><code>pthread_once</code></a>.</p> -<h3 id="Example"> Example</h3> <div class="t-example"> <div class="c source-c"><pre data-language="c">#include <stdio.h> -#include <threads.h> - -void do_once(void) { - puts("called once"); -} - -static once_flag flag = ONCE_FLAG_INIT; -int func(void* data) -{ - call_once(&flag, do_once); -} - -int main(void) -{ - thrd_t t1, t2, t3, t4; - thrd_create(&t1, func, NULL); - thrd_create(&t2, func, NULL); - thrd_create(&t3, func, NULL); - thrd_create(&t4, func, NULL); - - thrd_join(t1, NULL); - thrd_join(t2, NULL); - thrd_join(t3, NULL); - thrd_join(t4, NULL); -}</pre></div> <p>Output:</p> -<div class="text source-text"><pre data-language="c">called once</pre></div> </div> <h3 id="References"> References</h3> <ul> -<li> C17 standard (ISO/IEC 9899:2018): </li> -<ul> -<li> 7.26.2.1 The call_once function (p: 275) </li> -<li> 7.26.1/3 ONCE_FLAG_INIT (p: 274) </li> -</ul> -<li> C11 standard (ISO/IEC 9899:2011): </li> -<ul> -<li> 7.26.2.1 The call_once function (p: 378) </li> -<li> 7.26.1/3 ONCE_FLAG_INIT (p: 376) </li> -</ul> -</ul> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td colspan="2"> <span><a href="https://en.cppreference.com/w/cpp/thread/call_once" title="cpp/thread/call once">C++ documentation</a></span> for <code>call_once</code> </td> -</tr> </table> <div class="_attribution"> - <p class="_attribution-p"> - © cppreference.com<br>Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.<br> - <a href="https://en.cppreference.com/w/c/thread/call_once" class="_attribution-link">https://en.cppreference.com/w/c/thread/call_once</a> - </p> -</div> |
