sl@0: // Copyright (c) 1998-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: // e32test\power\async.h sl@0: // sl@0: // sl@0: sl@0: class RAsyncSwitchOff : public RThread sl@0: { sl@0: public: sl@0: TInt Start(TTimeIntervalMicroSeconds32 aTime); sl@0: TInt Wait(); sl@0: static TInt Thread(TAny* aPtr); sl@0: public: sl@0: TTimeIntervalMicroSeconds32 iTime; sl@0: TRequestStatus iStatus; sl@0: }; sl@0: sl@0: _LIT(KAsyncSwitchOffThreadName, "AsyncSwitchOffThread"); sl@0: sl@0: TInt RAsyncSwitchOff::Thread(TAny* aPtr) sl@0: { sl@0: RAsyncSwitchOff& a=*(RAsyncSwitchOff*)aPtr; sl@0: User::After(a.iTime); sl@0: UserHal::SwitchOff(); sl@0: return KErrNone; sl@0: } sl@0: sl@0: TInt RAsyncSwitchOff::Start(TTimeIntervalMicroSeconds32 aTime) sl@0: { sl@0: iTime=aTime; sl@0: TInt r=Create(KAsyncSwitchOffThreadName, Thread, 0x1000, NULL, this); sl@0: if (r!=KErrNone) sl@0: return r; sl@0: SetPriority(EPriorityMuchMore); sl@0: Logon(iStatus); sl@0: Resume(); sl@0: return KErrNone; sl@0: } sl@0: sl@0: TInt RAsyncSwitchOff::Wait() sl@0: { sl@0: User::WaitForRequest(iStatus); sl@0: TExitType exitType=ExitType(); sl@0: CLOSE_AND_WAIT(*this); sl@0: if (exitType!=EExitKill) sl@0: User::Panic(_L("AsyncSwitchOff"), iStatus.Int()); sl@0: return iStatus.Int(); sl@0: }