Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions | Variables
nsToolkit.cpp File Reference
#include "nsToolkit.h"
#include "prmon.h"
#include "prtime.h"
#include "nsGUIEvent.h"
#include "nsSwitchToUIThread.h"
#include "plevent.h"
#include "prprf.h"

Go to the source code of this file.

Classes

struct  ThreadInterfaceData
struct  ThreadInitInfo

Functions

NS_METHOD NS_GetCurrentToolkit (nsIToolkit **aResult)

Variables

static PRUintn gToolkitTLSIndex = 0
PRBool gThreadState = PR_FALSE

Class Documentation

struct ThreadInterfaceData

Definition at line 57 of file nsAppShell.cpp.

Class Members
void * data
thread_id waitingThread
struct ThreadInitInfo

Definition at line 70 of file nsToolkit.cpp.

Collaboration diagram for ThreadInitInfo:
Class Members
PRMonitor * monitor
nsToolkit * toolkit

Function Documentation

Definition at line 286 of file nsToolkit.cpp.

{ 
  nsIToolkit* toolkit = nsnull; 
  nsresult rv = NS_OK; 
  PRStatus status; 

  // Create the TLS index the first time through... 
  if (0 == gToolkitTLSIndex)  
  { 
    status = PR_NewThreadPrivateIndex(&gToolkitTLSIndex, NULL); 
    if (PR_FAILURE == status) 
    { 
      rv = NS_ERROR_FAILURE; 
    } 
  } 

  if (NS_SUCCEEDED(rv)) 
  { 
    toolkit = (nsIToolkit*)PR_GetThreadPrivate(gToolkitTLSIndex); 

    // 
    // Create a new toolkit for this thread... 
    // 
    if (!toolkit) 
    { 
      toolkit = new nsToolkit(); 

      if (!toolkit) 
      { 
        rv = NS_ERROR_OUT_OF_MEMORY; 
      } 
      else 
      { 
        NS_ADDREF(toolkit); 
        toolkit->Init(PR_GetCurrentThread()); 
        // 
        // The reference stored in the TLS is weak.  It is removed in the 
        // nsToolkit destructor... 
        // 
        PR_SetThreadPrivate(gToolkitTLSIndex, (void*)toolkit); 
      } 
    } 
    else 
    { 
      NS_ADDREF(toolkit); 
    } 
    *aResult = toolkit; 
  } 

  return rv; 
} 

Here is the call graph for this function:


Variable Documentation

Definition at line 68 of file nsToolkit.cpp.

PRUintn gToolkitTLSIndex = 0 [static]

Definition at line 50 of file nsToolkit.cpp.