Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions | Variables
prtpd.c File Reference
#include "primpl.h"
#include <string.h>

Go to the source code of this file.

Defines

#define _PR_TPD_LIMIT   128 /* arbitary limit on the TPD slots */
#define _PR_TPD_DESTRUCTOR_ITERATIONS   4

Functions

void _PR_InitTPD (void)
void _PR_CleanupTPD (void)
 PR_IMPLEMENT (PRStatus)
 PR_IMPLEMENT (void *)
void _PR_DestroyThreadPrivate (PRThread *self)

Variables

static PRInt32 _pr_tpd_length = 0
static PRInt32 _pr_tpd_highwater = 0
static PRThreadPrivateDTOR_pr_tpd_destructors = NULL

Define Documentation

#define _PR_TPD_LIMIT   128 /* arbitary limit on the TPD slots */

Definition at line 83 of file prtpd.c.


Function Documentation

Definition at line 105 of file prtpd.c.

{
}  /* _PR_CleanupTPD */

Here is the caller graph for this function:

Definition at line 244 of file prtpd.c.

{
#define _PR_TPD_DESTRUCTOR_ITERATIONS 4

    if (NULL != self->privateData)  /* we have some */
    {
        PRBool clean;
        PRUint32 index;
        PRInt32 passes = _PR_TPD_DESTRUCTOR_ITERATIONS;
        PR_ASSERT(0 != self->tpdLength);
        do
        {
            clean = PR_TRUE;
            for (index = 0; index < self->tpdLength; ++index)
            {
                void *priv = self->privateData[index];  /* extract */
                if (NULL != priv)  /* we have data at this index */
                {
                    if (NULL != _pr_tpd_destructors[index])
                    {
                        self->privateData[index] = NULL;  /* precondition */
                        (*_pr_tpd_destructors[index])(priv);  /* destroy */
                        clean = PR_FALSE;  /* unknown side effects */
                    }
                }
            }
        } while ((--passes > 0) && !clean);  /* limit # of passes */
        /*
        ** We give up after a fixed number of passes. Any non-NULL
        ** thread-private data value with a registered destructor
        ** function is not destroyed.
        */
        memset(self->privateData, 0, self->tpdLength * sizeof(void*));
    }
}  /* _PR_DestroyThreadPrivate */

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 94 of file prtpd.c.

Here is the caller graph for this function:

Definition at line 129 of file prtpd.c.

{
    PRStatus rv;
    PRInt32 index;

    if (!_pr_initialized) _PR_ImplicitInitialization();

    PR_ASSERT(NULL != newIndex);
    PR_ASSERT(NULL != _pr_tpd_destructors);

    index = PR_AtomicIncrement(&_pr_tpd_highwater) - 1;  /* allocate index */
    if (_PR_TPD_LIMIT <= index)
    {
        PR_SetError(PR_TPD_RANGE_ERROR, 0);
        rv = PR_FAILURE;  /* that's just wrong */
    }
    else
    {
        _pr_tpd_destructors[index] = dtor;  /* record destructor @index */
        *newIndex = (PRUintn)index;  /* copy into client's location */
        rv = PR_SUCCESS;  /* that's okay */
    }

    return rv;
}

Here is the call graph for this function:

PR_IMPLEMENT ( void )

Definition at line 230 of file prtpd.c.

{
    PRThread *self = PR_GetCurrentThread();
    void *tpd = ((NULL == self->privateData) || (index >= self->tpdLength)) ?
        NULL : self->privateData[index];

    return tpd;
}

Here is the call graph for this function:


Variable Documentation

Definition at line 86 of file prtpd.c.

PRInt32 _pr_tpd_highwater = 0 [static]

Definition at line 85 of file prtpd.c.

PRInt32 _pr_tpd_length = 0 [static]

Definition at line 84 of file prtpd.c.