Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Member Functions | Private Attributes
nsIOThreadPool Class Reference
Inheritance diagram for nsIOThreadPool:
Inheritance graph
[legend]
Collaboration diagram for nsIOThreadPool:
Collaboration graph
[legend]

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSIEVENTTARGET
NS_DECL_NSIOBSERVER nsresult 
Init ()
void Shutdown ()
void postEvent (in PLEventPtr aEvent)
 Method for posting an asynchronous event to the event target.
boolean isOnCurrentThread ()
 This method returns true if the event target is the current thread.
void observe (in nsISupports aSubject, in string aTopic, in wstring aData)
 Observe will be called when there is a notification for the topic |aTopic|.

Private Member Functions

virtual ~nsIOThreadPool ()
 PR_STATIC_CALLBACK (void) ThreadFunc(void *)

Private Attributes

PRLockmLock
PRCondVarmIdleThreadCV
PRCondVarmExitThreadCV
PRUint32 mNumThreads
PRUint32 mNumIdleThreads
PRCList mEventQ
PRBool mShutdown

Detailed Description

Definition at line 74 of file nsIOThreadPool.cpp.


Constructor & Destructor Documentation

nsIOThreadPool::~nsIOThreadPool ( ) [private, virtual]

Definition at line 135 of file nsIOThreadPool.cpp.

{
    LOG(("Destroying nsIOThreadPool @%p\n", this));

#ifdef DEBUG
    NS_ASSERTION(PR_CLIST_IS_EMPTY(&mEventQ), "leaking events");
    NS_ASSERTION(mNumThreads == 0, "leaking thread(s)");
#endif

    if (mIdleThreadCV)
        PR_DestroyCondVar(mIdleThreadCV);
    if (mExitThreadCV)
        PR_DestroyCondVar(mExitThreadCV);
    if (mLock)
        PR_DestroyLock(mLock);
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 103 of file nsIOThreadPool.cpp.

{
#if defined(PR_LOGGING)
    if (!gIOThreadPoolLog)
        gIOThreadPoolLog = PR_NewLogModule("nsIOThreadPool");
#endif

    mNumThreads = 0;
    mNumIdleThreads = 0;
    mShutdown = PR_FALSE;

    mLock = PR_NewLock();
    if (!mLock)
        return NS_ERROR_OUT_OF_MEMORY;

    mIdleThreadCV = PR_NewCondVar(mLock);
    if (!mIdleThreadCV)
        return NS_ERROR_OUT_OF_MEMORY;

    mExitThreadCV = PR_NewCondVar(mLock);
    if (!mExitThreadCV)
        return NS_ERROR_OUT_OF_MEMORY;

    PR_INIT_CLIST(&mEventQ);

    // we want to shutdown the i/o thread pool at xpcom-shutdown time...
    nsCOMPtr<nsIObserverService> os = do_GetService("@mozilla.org/observer-service;1");
    if (os)
        os->AddObserver(this, "xpcom-shutdown", PR_FALSE);
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

This method returns true if the event target is the current thread.

void nsIObserver::observe ( in nsISupports  aSubject,
in string  aTopic,
in wstring  aData 
) [inherited]

Observe will be called when there is a notification for the topic |aTopic|.

This assumes that the object implementing this interface has been registered with an observer service such as the nsIObserverService.

If you expect multiple topics/subjects, the impl is responsible for filtering.

You should not modify, add, remove, or enumerate notifications in the implemention of observe.

Parameters:
aSubject: Notification specific interface pointer.
aTopic: The notification topic or subject.
aData: Notification specific wide string. subject event.
void nsIEventTarget::postEvent ( in PLEventPtr  aEvent) [inherited]

Method for posting an asynchronous event to the event target.

If this method succeeds, then the event will be dispatched on the target thread.

Parameters:
aEventThe event to dispatched.

Definition at line 153 of file nsIOThreadPool.cpp.

{
    LOG(("nsIOThreadPool::Shutdown\n"));

    // synchronize with background threads...
    {
        nsAutoLock lock(mLock);
        mShutdown = PR_TRUE;

        PR_NotifyAllCondVar(mIdleThreadCV);

        while (mNumThreads != 0)
            PR_WaitCondVar(mExitThreadCV, PR_INTERVAL_NO_TIMEOUT);
    }
}

Here is the call graph for this function:


Member Data Documentation

PRCList nsIOThreadPool::mEventQ [private]

Definition at line 96 of file nsIOThreadPool.cpp.

Definition at line 93 of file nsIOThreadPool.cpp.

Definition at line 92 of file nsIOThreadPool.cpp.

Definition at line 91 of file nsIOThreadPool.cpp.

Definition at line 95 of file nsIOThreadPool.cpp.

Definition at line 94 of file nsIOThreadPool.cpp.

Definition at line 97 of file nsIOThreadPool.cpp.


The documentation for this class was generated from the following file: