os/kernelhwsrv/kerneltest/e32test/power/async.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // e32test\power\async.h
    15 // 
    16 //
    17 
    18 class RAsyncSwitchOff : public RThread
    19 	{
    20 public:
    21 	TInt Start(TTimeIntervalMicroSeconds32 aTime);
    22 	TInt Wait();
    23 	static TInt Thread(TAny* aPtr);
    24 public:
    25 	TTimeIntervalMicroSeconds32 iTime;
    26 	TRequestStatus iStatus;
    27 	};
    28 
    29 _LIT(KAsyncSwitchOffThreadName, "AsyncSwitchOffThread");
    30 
    31 TInt RAsyncSwitchOff::Thread(TAny* aPtr)
    32 	{
    33 	RAsyncSwitchOff& a=*(RAsyncSwitchOff*)aPtr;
    34 	User::After(a.iTime);
    35 	UserHal::SwitchOff();
    36 	return KErrNone;
    37 	}
    38 
    39 TInt RAsyncSwitchOff::Start(TTimeIntervalMicroSeconds32 aTime)
    40 	{
    41 	iTime=aTime;
    42 	TInt r=Create(KAsyncSwitchOffThreadName, Thread, 0x1000, NULL, this);
    43 	if (r!=KErrNone)
    44 		return r;
    45 	SetPriority(EPriorityMuchMore);
    46 	Logon(iStatus);
    47 	Resume();
    48 	return KErrNone;
    49 	}
    50 
    51 TInt RAsyncSwitchOff::Wait()
    52 	{
    53 	User::WaitForRequest(iStatus);
    54 	TExitType exitType=ExitType();
    55 	CLOSE_AND_WAIT(*this);
    56 	if (exitType!=EExitKill)
    57 		User::Panic(_L("AsyncSwitchOff"), iStatus.Int());
    58 	return iStatus.Int();
    59 	}