From 99aebd430a3a4f037cc10d14751afcb99fe0365f Mon Sep 17 00:00:00 2001 From: rpj Date: Mon, 9 May 2005 08:32:18 +0000 Subject: '' --- manual/pthread_key_create.html | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) (limited to 'manual/pthread_key_create.html') 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 @@ PTHREAD_SPECIFIC(3) manual page - + @@ -60,9 +60,9 @@ in all currently executing threads. a destructor function associated with the key. When a thread terminates via pthread_exit or by cancellation, destr_function is called with arguments the value associated with the key in that -thread. The destr_function is not called if that value is -NULL. The order in which destructor functions are called at -thread termination time is unspecified. +thread. The destr_function is not called if that value is NULL +or the key has been deleted. The order in which destructor +functions are called at thread termination time is unspecified.

Before the destructor function is called, the NULL value is associated with the key in the current thread. A destructor function @@ -70,11 +70,7 @@ might, however, re-associate non- NULL values to that key or some other key. To deal with this, if after all the destructors have been called for all non- NULL values, there are still some non- NULL values with associated destructors, then the process -is repeated. The Pthreads-w32 implementation stops the process after -PTHREAD_DESTRUCTOR_ITERATIONS iterations, even if some non- -NULL values with associated descriptors remain. Other -implementations may loop indefinitely. -

+is repeated.

pthread_key_delete deallocates a TSD key. It does not check whether non- NULL 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 pointer instead.

pthread_getspecific returns the value currently associated with key in the calling thread.

+

The routines pthread_setspecific, pthread_getspecific, +and pthread_key_delete can be called from destr_function +targeting any valid key including the key on which destr_function +is currently operating. If pthread_getspecific is called on +the key whose thread specific data is being destroyed, the value NULL +is returned, unless pthread_setspecific was called previously +on that key from within destr_function to set the value to +non-NULL. For some implementations the effect of calling +pthread_setspecific from within destr_function can be +either memory leakage or infinite loops if destr_function has +already been called at least PTHREAD_DESTRUCTOR_ITERATIONS +times.

+

Pthreads-w32 stops running key +destr_function routines after PTHREAD_DESTRUCTOR_ITERATIONS +iterations, even if some non- NULL values with associated +descriptors remain. If memory is allocated and associated with a key +from within destr_function, that memory may not be reclaimed +because that key's destr_function, may not run again.

Return Value

pthread_key_create, pthread_key_delete, and pthread_setspecific return 0 on success and a non-zero error @@ -105,7 +119,7 @@ error:

EAGAIN
-
+
PTHREAD_KEYS_MAX keys are already allocated
@@ -113,7 +127,7 @@ error:
ENOMEM
-
+
Insufficient memory to allocate the key.

pthread_key_delete and pthread_setspecific return @@ -171,8 +185,8 @@ static void buffer_destroy(void * buf) free(buf); }


-
Table of -Contents
+
+Table of Contents
  • Name
    @@ -194,4 +208,4 @@ Contents
- + \ No newline at end of file -- cgit v1.2.3