Returns a new index for a per-thread private data table and optionally associates a destructor with the data that will be assigned to the index.
#include <prthread.h> PRStatus PR_NewThreadPrivateIndex( PRUintn *newIndex, PRThreadPrivateDTOR destructor);
PR_NewThreadPrivateIndex
has the following parameters:
newIndex
PR_SetThreadPrivate
and PR_GetThreadPrivate
.destructor
PRThreadPrivateDTOR
for the private data associated with the index. This function can be specified as NULL
.The function returns one of the following values:
PR_SUCCESS
.PR_FAILURE
.If PR_NewThreadPrivateIndex
is successful, every thread in the same process is capable of associating private data with the new index. Until the data for an index is actually set, the value of the private data at that index is NULL
. You pass this index to PR_SetThreadPrivate
and PR_GetThreadPrivate
to set and retrieve data associated with the index.
When you allocate the index, you may also register a destructor function of type PRThreadPrivateDTOR
. If a destructor function is registered with a new index, it will be called at one of two times, as long as the private data is not NULL
:
PR_SetThreadPrivate
The index maintains independent data values for each binding thread. A thread can get access only to its own thread-specific data. There is no way to deallocate a private data index once it is allocated.