os/kernelhwsrv/kerneltest/e32test/power/async.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/power/async.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,59 @@
     1.4 +// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// e32test\power\async.h
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +class RAsyncSwitchOff : public RThread
    1.22 +	{
    1.23 +public:
    1.24 +	TInt Start(TTimeIntervalMicroSeconds32 aTime);
    1.25 +	TInt Wait();
    1.26 +	static TInt Thread(TAny* aPtr);
    1.27 +public:
    1.28 +	TTimeIntervalMicroSeconds32 iTime;
    1.29 +	TRequestStatus iStatus;
    1.30 +	};
    1.31 +
    1.32 +_LIT(KAsyncSwitchOffThreadName, "AsyncSwitchOffThread");
    1.33 +
    1.34 +TInt RAsyncSwitchOff::Thread(TAny* aPtr)
    1.35 +	{
    1.36 +	RAsyncSwitchOff& a=*(RAsyncSwitchOff*)aPtr;
    1.37 +	User::After(a.iTime);
    1.38 +	UserHal::SwitchOff();
    1.39 +	return KErrNone;
    1.40 +	}
    1.41 +
    1.42 +TInt RAsyncSwitchOff::Start(TTimeIntervalMicroSeconds32 aTime)
    1.43 +	{
    1.44 +	iTime=aTime;
    1.45 +	TInt r=Create(KAsyncSwitchOffThreadName, Thread, 0x1000, NULL, this);
    1.46 +	if (r!=KErrNone)
    1.47 +		return r;
    1.48 +	SetPriority(EPriorityMuchMore);
    1.49 +	Logon(iStatus);
    1.50 +	Resume();
    1.51 +	return KErrNone;
    1.52 +	}
    1.53 +
    1.54 +TInt RAsyncSwitchOff::Wait()
    1.55 +	{
    1.56 +	User::WaitForRequest(iStatus);
    1.57 +	TExitType exitType=ExitType();
    1.58 +	CLOSE_AND_WAIT(*this);
    1.59 +	if (exitType!=EExitKill)
    1.60 +		User::Panic(_L("AsyncSwitchOff"), iStatus.Int());
    1.61 +	return iStatus.Int();
    1.62 +	}