sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @internalComponent sl@0: */ sl@0: sl@0: #include "renderertimer.h" sl@0: #include "rendererrelay.h" sl@0: #include "rendererutil.h" sl@0: sl@0: /** C++ constructor */ sl@0: CRendererTimer::CRendererTimer(CRendererRelay& aRenderer) sl@0: : CTimer(EPriorityHigh), iRenderer(aRenderer) sl@0: { sl@0: CActiveScheduler::Add(this); sl@0: } sl@0: sl@0: /** Two-phased constructor. */ sl@0: CRendererTimer* CRendererTimer::NewL(CRendererRelay& aRenderer) sl@0: { sl@0: CRendererTimer* self = new (ELeave) CRendererTimer(aRenderer); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); // this call CTimer::ConstructL sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: /** Destructor */ sl@0: CRendererTimer::~CRendererTimer() sl@0: { sl@0: // cancel is called by CTimer destructor sl@0: } sl@0: sl@0: /** Start the renderer timer */ sl@0: void CRendererTimer::Start(TTimeIntervalMicroSeconds32 aDelay) sl@0: { sl@0: DEBUGPRINT2(_L("CRendererTimer::Start entered with aDelay=%d"), aDelay.Int()); sl@0: sl@0: __ASSERT_DEBUG(iRenderer.UpdateSubmitted() == EFalse, User::Panic(_L("CRT::Start"), KErrArgument)); sl@0: __ASSERT_DEBUG(IsActive() == EFalse, User::Panic(_L("CRT::Start"), KErrCorrupt)); sl@0: sl@0: HighRes(aDelay); sl@0: } sl@0: sl@0: /** Handle completion */ sl@0: void CRendererTimer::RunL() sl@0: { sl@0: DEBUGPRINT2(_L("CRendererTimer::RunL entered with status=%d"), iStatus.Int()); sl@0: sl@0: if (iStatus == KErrNone) sl@0: { sl@0: iRenderer.RendererTimerExpired(); sl@0: } sl@0: } sl@0: sl@0: sl@0: /** Two-phased constructor. */ sl@0: CThreadUndertaker* CThreadUndertaker::NewL(RThread& aSubThread) sl@0: { sl@0: CThreadUndertaker* self; sl@0: self = new (ELeave) CThreadUndertaker(aSubThread); sl@0: return self; sl@0: } sl@0: sl@0: /** Constructor for the class. */ sl@0: CThreadUndertaker::CThreadUndertaker(RThread& aSubThread) sl@0: : CActive(CActive::EPriorityIdle), iSubThread(aSubThread) sl@0: { sl@0: CActiveScheduler::Add(this); sl@0: sl@0: iStatus = KRequestPending; sl@0: SetActive(); sl@0: sl@0: //Logon to the thread so we will receive signals sl@0: iSubThread.Logon(iStatus); sl@0: } sl@0: sl@0: /** Destructor for this class. */ sl@0: CThreadUndertaker::~CThreadUndertaker() sl@0: { sl@0: Cancel(); sl@0: } sl@0: sl@0: /** This function is triggered when the thread being monitored terminates. */ sl@0: void CThreadUndertaker::RunL() sl@0: { sl@0: // If the thread being monitored panic, panic this thread. sl@0: TInt reason = iSubThread.ExitReason(); sl@0: TExitCategoryName category = iSubThread.ExitCategory(); sl@0: User::Panic(category, reason); sl@0: } sl@0: sl@0: /** Stop monitoring the thread for panics. */ sl@0: void CThreadUndertaker::DoCancel() sl@0: { sl@0: iSubThread.LogonCancel(iStatus); sl@0: }