summaryrefslogtreecommitdiff
path: root/manual/pthread_key_create.html
diff options
context:
space:
mode:
Diffstat (limited to 'manual/pthread_key_create.html')
-rw-r--r--manual/pthread_key_create.html42
1 files changed, 28 insertions, 14 deletions
diff --git a/manual/pthread_key_create.html b/manual/pthread_key_create.html
index 9d9e004..5ecca69 100644
--- a/manual/pthread_key_create.html
+++ b/manual/pthread_key_create.html
@@ -5,7 +5,7 @@
<TITLE>PTHREAD_SPECIFIC(3) manual page</TITLE>
<META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)">
<META NAME="CREATED" CONTENT="20050504;18425400">
- <META NAME="CHANGED" CONTENT="20050505;18330000">
+ <META NAME="CHANGED" CONTENT="20050509;18220200">
<!-- manual page source format generated by PolyglotMan v3.2, -->
<!-- available at http://polyglotman.sourceforge.net/ -->
</HEAD>
@@ -60,9 +60,9 @@ in all currently executing threads.
a destructor function associated with the key. When a thread
terminates via <B>pthread_exit</B> or by cancellation, <I>destr_function</I>
is called with arguments the value associated with the key in that
-thread. The <I>destr_function</I> is not called if that value is
-<B>NULL</B>. The order in which destructor functions are called at
-thread termination time is unspecified.
+thread. The <I>destr_function</I> is not called if that value is <B>NULL</B><SPAN STYLE="font-weight: medium">
+or the key has been deleted</SPAN>. The order in which destructor
+functions are called at thread termination time is unspecified.
</P>
<P>Before the destructor function is called, the <B>NULL</B> value is
associated with the key in the current thread. A destructor function
@@ -70,11 +70,7 @@ might, however, re-associate non- <B>NULL</B> values to that key or
some other key. To deal with this, if after all the destructors have
been called for all non- <B>NULL</B> values, there are still some
non- <B>NULL</B> values with associated destructors, then the process
-is repeated. The <B>Pthreads-w32</B> implementation stops the process after
-<B>PTHREAD_DESTRUCTOR_ITERATIONS</B> iterations, even if some non-
-<B>NULL</B> values with associated descriptors remain. Other
-implementations may loop indefinitely.
-</P>
+is repeated.</P>
<P><B>pthread_key_delete</B> deallocates a TSD key. It does not check
whether non- <B>NULL</B> values are associated with that key in the
currently executing threads, nor call the destructor function
@@ -86,6 +82,24 @@ in the calling thread, storing the given <I>pointer</I> instead.
<P><B>pthread_getspecific</B> returns the value currently associated
with <I>key</I> in the calling thread.
</P>
+<P>The routines <B>pthread_setspecific</B>, <B>pthread_getspecific</B>,
+and <B>pthread_key_delete</B> can be called from <I>destr_function</I>
+targeting any valid key including the key on which <I>destr_function</I>
+is currently operating. If <B>pthread_getspecific</B> is called on
+the key whose thread specific data is being destroyed, the value NULL
+is returned, unless <B>pthread_setspecific</B> was called previously
+on that key from within <I>destr_function</I> to set the value to
+non-NULL. For some implementations the effect of calling
+<B>pthread_setspecific</B> from within <I>destr_function</I> can be
+either memory leakage or infinite loops if <I>destr_function</I> has
+already been called at least <B>PTHREAD_DESTRUCTOR_ITERATIONS</B>
+times.</P>
+<P STYLE="font-weight: medium"><B>Pthreads-w32</B> stops running key
+<I>destr_function</I> routines after <B>PTHREAD_DESTRUCTOR_ITERATIONS</B>
+iterations, even if some non- <B>NULL</B> values with associated
+descriptors remain. If memory is allocated and associated with a key
+from within <I>destr_function</I>, that memory may not be reclaimed
+because that key's <I>destr_function</I>, may not run again.</P>
<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2>
<P><B>pthread_key_create</B>, <B>pthread_key_delete</B>, and
<B>pthread_setspecific</B> return 0 on success and a non-zero error
@@ -105,7 +119,7 @@ error:
<DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EAGAIN</B>
</DT></DL>
</DL>
-<BLOCKQUOTE STYLE="margin-left: 3cm">
+<BLOCKQUOTE STYLE="margin-left: 5cm">
<B>PTHREAD_KEYS_MAX</B> keys are already allocated
</BLOCKQUOTE>
<DL>
@@ -113,7 +127,7 @@ error:
<DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>ENOMEM</B>
</DT></DL>
</DL>
-<BLOCKQUOTE STYLE="margin-left: 3cm">
+<BLOCKQUOTE STYLE="margin-left: 5cm">
Insufficient memory to allocate the key.
</BLOCKQUOTE>
<P><B>pthread_key_delete</B> and <B>pthread_setspecific</B> return
@@ -171,8 +185,8 @@ static void buffer_destroy(void * buf)
free(buf);
}</PRE>
<HR>
-<BLOCKQUOTE STYLE="margin-left: 0cm"><A NAME="toc"></A><B>Table of
-Contents</B></BLOCKQUOTE>
+<BLOCKQUOTE STYLE="margin-left: 0cm; margin-right: 0cm"><A NAME="toc"></A>
+<B>Table of Contents</B></BLOCKQUOTE>
<UL>
<LI><BLOCKQUOTE STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A>
</BLOCKQUOTE>
@@ -194,4 +208,4 @@ Contents</B></BLOCKQUOTE>
</BLOCKQUOTE>
</UL>
</BODY>
-</HTML>
+</HTML> \ No newline at end of file