VirtualBox

Changeset 101991 in vbox for trunk/src


Ignore:
Timestamp:
Nov 8, 2023 5:34:06 PM (18 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
160088
Message:

libs/xpcom: Convert nsThread.cpp from PR_LOG to IPRT's logging infrastructure, bugref:10545

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/xpcom/threads/nsThread.cpp

    r101982 r101991  
    3838#include "nsThread.h"
    3939#include "prmem.h"
    40 #include "prlog.h"
    4140#include "nsAutoLock.h"
    4241
    4342#include <iprt/assert.h>
     43#include <VBox/log.h>
    4444
    4545RTTLS nsThread::kIThreadSelfIndex = NIL_RTTLS;
    4646static nsIThread *gMainThread = 0;
    4747
    48 #if defined(PR_LOGGING)
    49 //
    50 // Log module for nsIThread logging...
    51 //
    52 // To enable logging (see prlog.h for full details):
    53 //
    54 //    set NSPR_LOG_MODULES=nsIThread:5
    55 //    set NSPR_LOG_FILE=nspr.log
    56 //
    57 // this enables PR_LOG_DEBUG level information and places all output in
    58 // the file nspr.log
    59 //
    60 // gSocketLog is defined in nsSocketTransport.cpp
    61 //
    62 PRLogModuleInfo* nsIThreadLog = nsnull;
    63 
    64 #endif /* PR_LOGGING */
    65 
    6648////////////////////////////////////////////////////////////////////////////////
    6749
     
    6951    : mThread(nsnull), mDead(PR_FALSE), mStartLock(nsnull)
    7052{
    71 #if defined(PR_LOGGING)
    72     //
    73     // Initialize the global PRLogModule for nsIThread logging
    74     // if necessary...
    75     //
    76     if (nsIThreadLog == nsnull) {
    77         nsIThreadLog = PR_NewLogModule("nsIThread");
    78     }
    79 #endif /* PR_LOGGING */
    80 
    8153    // enforce matching of constants to enums in prthread.h
    8254    NS_ASSERTION(int(nsIThread::PRIORITY_LOW)     == int(PR_PRIORITY_LOW) &&
     
    9668        PR_DestroyLock(mStartLock);
    9769
    98     PR_LOG(nsIThreadLog, PR_LOG_DEBUG,
    99            ("nsIThread %p destroyed\n", this));
     70    Log(("nsIThread %p destroyed\n", this));
    10071
    10172    // This code used to free the nsIThreadLog loginfo stuff
     
    11687    NS_ASSERTION(rv == NS_OK, "failed to set thread self");
    11788
    118     PR_LOG(nsIThreadLog, PR_LOG_DEBUG,
    119            ("nsIThread %p start run %p\n", self, self->mRunnable.get()));
     89    Log(("nsIThread %p start run %p\n", self, self->mRunnable.get()));
    12090    rv = self->mRunnable->Run();
    12191    NS_ASSERTION(NS_SUCCEEDED(rv), "runnable failed");
    12292
    123 #ifdef DEBUG
     93#ifdef LOG_ENABLED
    12494    // Because a thread can die after gMainThread dies and takes nsIThreadLog with it,
    12595    // we need to check for it being null so that we don't crash on shutdown.
    126     if (nsIThreadLog) {
    127       PRThreadState state;
    128       rv = self->GetState(&state);
    129       PR_LOG(nsIThreadLog, PR_LOG_DEBUG,
    130              ("nsIThread %p end run %p\n", self, self->mRunnable.get()));
    131     }
     96    PRThreadState state;
     97    rv = self->GetState(&state);
     98    Log(("nsIThread %p end run %p\n", self, self->mRunnable.get()));
    13299#endif
    133100
     
    149116    self->mDead = PR_TRUE;
    150117
    151 #if defined(PR_LOGGING)
    152     if (nsIThreadLog) {
    153       PR_LOG(nsIThreadLog, PR_LOG_DEBUG,
    154              ("nsIThread %p exited\n", self));
    155     }
    156 #endif
     118    Log(("nsIThread %p exited\n", self));
    157119    NS_RELEASE(self);
    158120}
     
    176138    // thread-local storage) before they let us join with the thread
    177139
    178     PR_LOG(nsIThreadLog, PR_LOG_DEBUG,
    179            ("nsIThread %p start join\n", this));
     140    Log(("nsIThread %p start join\n", this));
    180141    if (!mThread)
    181142        return NS_ERROR_NOT_INITIALIZED;
     
    183144    // XXX can't use NS_RELEASE here because the macro wants to set
    184145    // this to null (bad c++)
    185     PR_LOG(nsIThreadLog, PR_LOG_DEBUG,
    186            ("nsIThread %p end join\n", this));
     146    Log(("nsIThread %p end join\n", this));
    187147    if (status == PR_SUCCESS) {
    188148        NS_RELEASE_THIS();   // most likely the final release of this thread
     
    279239                              priority, scope, state, stackSize);
    280240    PR_Unlock(mStartLock);
    281     PR_LOG(nsIThreadLog, PR_LOG_DEBUG,
    282            ("nsIThread %p created\n", this));
     241    Log(("nsIThread %p created\n", this));
    283242
    284243    if (mThread == nsnull)
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette