blob: 3540ac07ac068960fb349b67b8a5ce0b5f3cd2a7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
<h1 id="firstHeading" class="firstHeading">tss_delete</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 tss_delete( tss_t tss_id );</pre>
</td> <td class="t-dcl-nopad"> </td> <td> <span class="t-mark-rev t-since-c11">(since C11)</span> </td> </tr> </table> <p>Destroys the thread-specific storage identified by <code>tss_id</code>.</p>
<p>The destructor, if one was registered by <code><a href="tss_create" title="c/thread/tss create">tss_create</a></code>, is not called (they are only called at thread exit, either by <code><a href="thrd_exit" title="c/thread/thrd exit">thrd_exit</a></code> or by returning from the thread function), it is the responsibility of the programmer to ensure that every thread that is aware of <code>tss_id</code> performed all necessary cleanup, before the call to <code>tss_delete</code> is made.</p>
<p>If <code>tss_delete</code> is called while another thread is executing destructors for <code>tss_id</code>, it's unspecified whether this changes the number of invocations to the associated destructor.</p>
<p>If <code>tss_delete</code> is called while the calling thread is executing destructors, then the destructor associated with <code>tss_id</code> will not be executed again on this thread.</p>
<h3 id="Parameters"> Parameters</h3> <table class="t-par-begin"> <tr class="t-par"> <td> tss_id </td> <td> - </td> <td> thread-specific storage key previously returned by <code><a href="tss_create" title="c/thread/tss create">tss_create</a></code> and not yet deleted by <code>tss_delete</code> </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_key_delete.html"><code>pthread_key_delete</code></a>.</p>
<p>The reason <code>tss_delete</code> never calls destructors is that the destructors (called at thread exit) are normally intended to be executed by the same thread that originally set the value (via <code><a href="tss_set" title="c/thread/tss set">tss_set</a></code>) that the destructor will be dealing with, and may even rely on the values of that or other thread-specific data as seen by that thread. The thread executing <code>tss_delete</code> has no access to other threads' TSS. Even if it were possible to call the destructor for each thread's own value associated with <code>tss_id</code>, <code>tss_delete</code> would have to synchronize with every thread if only to examine whether the value of this TSS in that thread is null (destructors are only called against non-null values).</p>
<h3 id="Example"> Example</h3> <h3 id="References"> References</h3> <ul>
<li> C17 standard (ISO/IEC 9899:2018): </li>
<ul><li> 7.26.6.2 The tss_delete function (p: 282) </li></ul>
<li> C11 standard (ISO/IEC 9899:2011): </li>
<ul><li> 7.26.6.2 The tss_delete function (p: 386) </li></ul>
</ul> <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/tss_delete" class="_attribution-link">https://en.cppreference.com/w/c/thread/tss_delete</a>
</p>
</div>
|