sl@0: /* 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 the License "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: * Implements the timer which stops the server after no sessions have been sl@0: * open for a defined period. sl@0: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @file sl@0: */ sl@0: sl@0: #include sl@0: sl@0: sl@0: CShutdownTimer* CShutdownTimer::NewL(TInt aDelayUs) sl@0: /** sl@0: Factory function allocates a new, initialized instance of CShutdownTimer. sl@0: sl@0: @param aDelayUs Delay in microseconds. sl@0: @return New, initialized instance of CShutdownTimer. sl@0: The newly-created object is owned by the caller. sl@0: */ sl@0: { sl@0: CShutdownTimer* self = new(ELeave) CShutdownTimer(aDelayUs); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); // CTimer implementation sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: CShutdownTimer::CShutdownTimer(TInt aDelayUs) sl@0: /** sl@0: Record the shutdown period and add this object to the active scheduler. sl@0: sl@0: @param aDelayUs Delay in microseconds. sl@0: */ sl@0: : CTimer(CActive::EPriorityStandard), sl@0: iDelayUs(aDelayUs) sl@0: { sl@0: CActiveScheduler::Add(this); sl@0: } sl@0: sl@0: void CShutdownTimer::Restart() sl@0: /** sl@0: Restart this timer. This timer should not be active when this sl@0: function is called. sl@0: sl@0: Once started, the timer can be stopped with the base class' Cancel function. sl@0: */ sl@0: { sl@0: if(iImmediateTimeoutNextRestart) sl@0: { sl@0: CActiveScheduler::Stop(); sl@0: return; sl@0: } sl@0: sl@0: // Start idle timeout sl@0: After(iDelayUs); sl@0: } sl@0: sl@0: void CShutdownTimer::ImmediateTimeoutNextRestart() sl@0: /** sl@0: Timer should immediately expire when Restart is next called. sl@0: */ sl@0: { sl@0: iImmediateTimeoutNextRestart = ETrue; sl@0: } sl@0: sl@0: sl@0: void CShutdownTimer::RunL() sl@0: /** sl@0: Implement CActive by stopping the active scheduler, which sl@0: has the effect of breaking out of the server loop. sl@0: */ sl@0: { sl@0: CActiveScheduler::Stop(); sl@0: } sl@0: