videoscheduler/SchedulerServer/src/CCseSemaphoreController.cpp
branchRCL_3
changeset 23 13a33d82ad98
parent 0 822a42b6c3f1
equal deleted inserted replaced
22:826cea16efd9 23:13a33d82ad98
       
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:    Observer for plugin thread if shutdown is signalled.*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "CCseSemaphoreController.h"
       
    21 #include "MCseSemaphoreSignalObserver.h"
       
    22 #include "CseDebug.h"               // Debug macros
       
    23 
       
    24 
       
    25 
       
    26 // EXTERNAL DATA STRUCTURES
       
    27 // None
       
    28 
       
    29 // EXTERNAL FUNCTION PROTOTYPES  
       
    30 // None
       
    31 
       
    32 // CONSTANTS
       
    33 // None
       
    34 
       
    35 // MACROS
       
    36 // None
       
    37 
       
    38 // LOCAL CONSTANTS AND MACROS
       
    39 static TUint KCSeSemaphorePollingInterval = 5000;
       
    40 
       
    41 // MODULE DATA STRUCTURES
       
    42 // None
       
    43 
       
    44 // LOCAL FUNCTION PROTOTYPES
       
    45 // None
       
    46 
       
    47 // FORWARD DECLARATIONS
       
    48 // None
       
    49 
       
    50 
       
    51 // ============================ MEMBER FUNCTIONS ===============================
       
    52 // ---------------------------------------------------------------------------
       
    53 // CCseSchedulerTimer::CCseSemaphoreController()
       
    54 //
       
    55 // ---------------------------------------------------------------------------
       
    56 CCseSemaphoreController::CCseSemaphoreController( RSemaphore& aSemaphore,
       
    57                                                   MCseSemaphoreSignalObserver& aObserver )
       
    58                             : CTimer( EPriorityNormal ),
       
    59                               iSemaphore( aSemaphore ),
       
    60                               iObserver( aObserver ),
       
    61                               iInterval( KCSeSemaphorePollingInterval )
       
    62                               
       
    63                             
       
    64 	{
       
    65 	CSELOGSTRING_HIGH_LEVEL(">>>CCseSemaphoreController::CCseSemaphoreController");
       
    66 	
       
    67 	CSELOGSTRING_HIGH_LEVEL("<<<CCseSemaphoreController::CCseSemaphoreController");
       
    68 	}
       
    69 
       
    70 // ---------------------------------------------------------------------------
       
    71 // CCseSchedulerTimer::~CCseSemaphoreController()
       
    72 //
       
    73 // ---------------------------------------------------------------------------	
       
    74 CCseSemaphoreController::~CCseSemaphoreController()
       
    75 	{
       
    76 	CSELOGSTRING_HIGH_LEVEL(">>>CCseSemaphoreController::~CCseSemaphoreController");
       
    77 	
       
    78 	Cancel();
       
    79 		
       
    80 	CSELOGSTRING_HIGH_LEVEL("<<<CCseSemaphoreController::~CCseSemaphoreController");
       
    81 	}
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 // CCseSchedulerTimer::NewL()
       
    85 //
       
    86 // ---------------------------------------------------------------------------	
       
    87 CCseSemaphoreController* CCseSemaphoreController::NewL( RSemaphore& aSemaphore,
       
    88                                                         MCseSemaphoreSignalObserver& aObserver )
       
    89 	{	
       
    90 	CSELOGSTRING_HIGH_LEVEL(">>>CCseSemaphoreController::NewL");
       
    91 	
       
    92 	// Symbian C++ constructor
       
    93 	CCseSemaphoreController* self = new ( ELeave ) CCseSemaphoreController( aSemaphore,
       
    94 	                                                                        aObserver );
       
    95     CleanupStack::PushL( self );
       
    96     self->ConstructL();
       
    97     CleanupStack::Pop( self );
       
    98     
       
    99 	CSELOGSTRING_HIGH_LEVEL("<<<CCseSemaphoreController::NewL");
       
   100     return self;
       
   101 	}
       
   102 	
       
   103 // ---------------------------------------------------------------------------
       
   104 // CCseSemaphoreController::ConstructL()
       
   105 //
       
   106 // ---------------------------------------------------------------------------
       
   107 void CCseSemaphoreController::ConstructL()
       
   108 	{
       
   109 	CSELOGSTRING_HIGH_LEVEL(">>>CCseSemaphoreController::ConstructL");	
       
   110 	    
       
   111     CTimer::ConstructL();
       
   112     CActiveScheduler::Add( this );
       
   113        
       
   114     CSELOGSTRING_HIGH_LEVEL("<<<CCseSemaphoreController::ConstructL");
       
   115 	}
       
   116 
       
   117 // -----------------------------------------------------------------------------
       
   118 // CCseSemaphoreController::Start
       
   119 //
       
   120 // -----------------------------------------------------------------------------
       
   121 //
       
   122 void CCseSemaphoreController::Start( )
       
   123     {                    
       
   124     Cancel();
       
   125 
       
   126     After( TTimeIntervalMicroSeconds32( iInterval ) );    
       
   127     }
       
   128     
       
   129 // -----------------------------------------------------------------------------
       
   130 // CCseSemaphoreController::Stop
       
   131 //
       
   132 // -----------------------------------------------------------------------------
       
   133 //
       
   134 void CCseSemaphoreController::Stop( )
       
   135     {
       
   136     Cancel();
       
   137     }    
       
   138 
       
   139 // -----------------------------------------------------------------------------
       
   140 // CCseSemaphoreController::SetInterval
       
   141 //
       
   142 // -----------------------------------------------------------------------------
       
   143 //
       
   144 void CCseSemaphoreController::SetInterval( TUint aInterval )
       
   145     {    
       
   146     iInterval = aInterval;
       
   147     }
       
   148 
       
   149 // -----------------------------------------------------------------------------
       
   150 // CCseSemaphoreController::RunL
       
   151 //
       
   152 // -----------------------------------------------------------------------------
       
   153 //
       
   154 void CCseSemaphoreController::RunL( )
       
   155     {
       
   156      // Check if shutdown is signalled
       
   157 	if( KErrNone == iSemaphore.Wait( 1 ) )
       
   158 	    {    	        
       
   159 	    CSELOGSTRING_HIGH_LEVEL("CCseSemaphoreController::RunL - Semaphore signalled, inform observer");
       
   160 	    // Shutdown signalled, start taking down the plugin	    
       
   161 	    iObserver.SemaphoreSignalled();
       
   162 	    Cancel();
       
   163 	    }    
       
   164     else
       
   165         {
       
   166         // If not, start again.
       
   167         Start();
       
   168         }
       
   169     }
       
   170 
       
   171 
       
   172 
       
   173 // End of file