Back to index

lightning-sunbird  0.9+nobinonly
Functions
nsslocks.c File Reference
#include "seccomon.h"
#include "nsslocks.h"
#include "pratom.h"
#include "prthread.h"

Go to the source code of this file.

Functions

SECStatus __nss_InitLock (PZLock **ppLock, nssILockType ltype)
SECStatus nss_InitLock (PZLock **ppLock, nssILockType ltype)
SECStatus nss_InitMonitor (PZMonitor **ppMonitor, nssILockType ltype)

Function Documentation

SECStatus __nss_InitLock ( PZLock **  ppLock,
nssILockType  ltype 
)

Definition at line 56 of file nsslocks.c.

{
    static PRInt32  initializers;

    PORT_Assert( ppLock != NULL);

    /* atomically initialize the lock */
    while (!*ppLock) {
        PRInt32 myAttempt = PR_AtomicIncrement(&initializers);
        if (myAttempt == 1) {
            if (!*ppLock) {
                *ppLock = PZ_NewLock(ltype);
            }
            (void) PR_AtomicDecrement(&initializers);
            break;
        }
        PR_Sleep(PR_INTERVAL_NO_WAIT);          /* PR_Yield() */
        (void) PR_AtomicDecrement(&initializers);
    }

    return (*ppLock != NULL) ? SECSuccess : SECFailure;
}

Here is the call graph for this function:

SECStatus nss_InitLock ( PZLock **  ppLock,
nssILockType  ltype 
)

Definition at line 80 of file nsslocks.c.

{
    return __nss_InitLock(ppLock, ltype);
}

Here is the call graph for this function:

SECStatus nss_InitMonitor ( PZMonitor **  ppMonitor,
nssILockType  ltype 
)

Definition at line 91 of file nsslocks.c.

{
    static PRInt32  initializers;

    PORT_Assert( ppMonitor != NULL);

    /* atomically initialize the lock */
    while (!*ppMonitor) {
        PRInt32 myAttempt = PR_AtomicIncrement(&initializers);
        if (myAttempt == 1) {
            if (!*ppMonitor) {
                *ppMonitor = PZ_NewMonitor(ltype);
            }
            (void) PR_AtomicDecrement(&initializers);
            break;
        }
        PR_Sleep(PR_INTERVAL_NO_WAIT);          /* PR_Yield() */
        (void) PR_AtomicDecrement(&initializers);
    }

    return (*ppMonitor != NULL) ? SECSuccess : SECFailure;
}

Here is the call graph for this function: