qtinternetradio/irqstatisticsreporter/src/irqstatisticsreporter.cpp
changeset 14 896e9dbc5f19
parent 3 ee64f059b8e1
equal deleted inserted replaced
12:608f67c22514 14:896e9dbc5f19
    20 #include "irqstatisticsreporter_symbian_p.h"
    20 #include "irqstatisticsreporter_symbian_p.h"
    21 #endif
    21 #endif
    22 
    22 
    23 QMutex IRQStatisticsReporter::mMutex;
    23 QMutex IRQStatisticsReporter::mMutex;
    24 int IRQStatisticsReporter::mRef = 0;
    24 int IRQStatisticsReporter::mRef = 0;
    25 IRQStatisticsReporter *IRQStatisticsReporter::mInstatnce = NULL;
    25 IRQStatisticsReporter *IRQStatisticsReporter::mInstance = NULL;
    26 
    26 
    27 // ---------------------------------------------------------------------------
    27 // ---------------------------------------------------------------------------
    28 // IRQStatisticsReporter::openInstance()
    28 // IRQStatisticsReporter::openInstance()
    29 // Static function to get a singleton instance of IRQStatisticsReporter
    29 // Static function to get a singleton instance of IRQStatisticsReporter
    30 // ---------------------------------------------------------------------------
    30 // ---------------------------------------------------------------------------
    31 //
    31 //
    32 IRQStatisticsReporter* IRQStatisticsReporter::openInstance()
    32 IRQStatisticsReporter* IRQStatisticsReporter::openInstance()
    33 {
    33 {
    34     mMutex.lock();
    34     mMutex.lock();
    35     if( NULL == mInstatnce )
    35     if( NULL == mInstance )
    36     {
    36     {
    37         mInstatnce = new IRQStatisticsReporter();
    37         mInstance = new IRQStatisticsReporter();
    38     }       
    38     }       
    39     if( mInstatnce != NULL )
    39     if( mInstance != NULL )
    40     {
    40     {
    41         mRef++;
    41         mRef++;
    42     }
    42     }
    43     mMutex.unlock();
    43     mMutex.unlock();
    44     return mInstatnce;
    44     return mInstance;
    45 }
    45 }
    46 
    46 
    47 // ---------------------------------------------------------------------------
    47 // ---------------------------------------------------------------------------
    48 // IRQStatisticsReporter::closeInstance()
    48 // IRQStatisticsReporter::closeInstance()
    49 // Close a singleton instance of IRQStatisticsReporter
    49 // Close a singleton instance of IRQStatisticsReporter
    50 // ---------------------------------------------------------------------------
    50 // ---------------------------------------------------------------------------
    51 //
    51 //
    52 void IRQStatisticsReporter::closeInstance()
    52 void IRQStatisticsReporter::closeInstance()
    53 {
    53 {
    54     if( mInstatnce != NULL )
    54     if( mInstance != NULL )
    55     {
    55     {
    56         mMutex.lock();
    56         mMutex.lock();
    57         mRef--;
    57         mRef--;
    58         if( 0 == mRef )
    58         if( 0 == mRef )
    59         {
    59         {
    60             delete mInstatnce;
    60             delete mInstance;
       
    61             mInstance = NULL;
    61         }        
    62         }        
    62         mMutex.unlock();
    63         mMutex.unlock();
    63     }
    64     }
    64 }
    65 }
    65 
    66