void StartSchedulerForAWhile178L(TTimeIntervalMicroSeconds32 aTimeout) { CPeriodic* timer = CPeriodic::NewL(CActive::EPriorityStandard); CleanupStack::PushL(timer); timer->Start(aTimeout, aTimeout, TCallBack(Timeout178)); CActiveScheduler::Start(); CleanupStack::PopAndDestroy(timer); }
void CAlfPerfAppAvkonTestCaseBasic::NextCycleL() { TAlfCustomEventCommand command( KAlfPerfAppAvkonCmdNext, this ); User::LeaveIfError( Env().Send( command, KCycleDurationMs ) ); iCycleCounter++; iAnimTimer->Cancel(); iAnimTimer->Start(KAnimSleepTimeUs, KAnimSleepTimeUs, TCallBack(AnimTimerCbL, this)); iAnimFrameNum = 0; iCycleStartTime.UniversalTime(); }
/** * Allows other active objects to run while waiting for the specified time. * */ void CTestStepCsdAgt::DelayL(TInt aMicroseconds) { // Construct and start the timer TCallBack callbackfn(CTestStepCsdAgt::TimerCallback, this); CPeriodic *regularUpdater = CPeriodic::NewL(CActive::EPriorityStandard); CleanupStack::PushL(regularUpdater); regularUpdater->Start(aMicroseconds,aMicroseconds,callbackfn); // Block until timer complete CActiveScheduler::Start(); // Stop and delete the timer regularUpdater->Cancel(); CleanupStack::PopAndDestroy(); }
// // Thread to run the client code // TInt ClientThread(TAny*) { RTest test(_L("T_SCHEDRACE client")); test.Title(); // UserSvr::FsRegisterThread(); test.Start(_L("Create Session")); TheSession = new RTestSession(&test, 5*60*64); // will run for 5 minutes test_NotNull(TheSession); test_KErrNone(TheSession->Connect(KServerName, 2)); test.Start(_L("Create and install ActiveScheduler")); CActiveScheduler* pScheduler = new CActiveScheduler; test_NotNull(pScheduler); CActiveScheduler::Install(pScheduler); test.Next(_L("Create timer and idle task")); CPeriodic* pTimer = CPeriodic::New(CActive::EPriorityStandard); test_NotNull(pTimer); CIdler* pIdler = new CIdler(); test_NotNull(pIdler); test.Next(_L("Rendezvous with main thread")); RThread self; self.Rendezvous(KErrNone); test.Next(_L("Start idle task, timer, and active scheduler")); pIdler->Start(TCallBack(IdleCallback, pIdler)); pTimer->Start(1000000, 1000, TCallBack(TimerCallback, pTimer)); test.Printf(_L(" There might be something going on beneath this window\n")); CActiveScheduler::Start(); // This code is not reached until the active scheduler exits. TheSession->SendSync(CTestSession::EStop, TIpcArgs()); TheSession->Close(); test.Next(_L("Destroy Idle task, Timer, and ActiveScheduler")); delete pIdler; delete pTimer; delete pScheduler; test.Close(); return (KErrNone); }
void CActiveConsole::ProcessValue() { switch (iCmdGetValue) { case 'C' : if (iValue > 0 && gNextChunk < MAX_CHUNKS) { CreateChunk (&gChunk[gNextChunk], iValue); ReadChunk (&gChunk[gNextChunk]); ShowMemoryUse(); gNextChunk++; } break; case 'H' : CacheSize (0,iValue); break; case 'L' : CacheSize (iValue,0); break; case 'P' : iPeriod = iValue; iActions = (TUint16)(iValue < KFlushQuietLimit ? EFlushQuiet : EFlush); iTimer->Cancel(); if (iValue > 0) { iTimer->Start(0,iValue,TCallBack(Callback,this)); } break; default : break; } iCmdGetValue = 0; iPrompt = ETrue; }
void CFeatureNotifierStepBase::WaitL( TInt aIntervalInMicorseconds ) { TWaitInfo info; // Construct periodic CPeriodic* periodic = CPeriodic::NewL( CActive::EPriorityStandard ); CleanupStack::PushL( periodic ); info.iPeriodic = periodic; // Construct active scheduler wait CActiveSchedulerWait* wait = new( ELeave ) CActiveSchedulerWait; CleanupStack::PushL( wait ); info.iWait = wait; iWait = wait; // Start timer and wait TCallBack cb( WaitCallBack, &info ); periodic->Start( aIntervalInMicorseconds, aIntervalInMicorseconds, cb ); wait->Start(); // Cleanup CleanupStack::PopAndDestroy( wait ); CleanupStack::PopAndDestroy( periodic ); }
TVerdict CStepProcMonIgnore::doTestStepL() { INFO_PRINTF1(_L("TEST APPFWK-SYSMON-0005")); INFO_PRINTF1(_L("Going to start a process")); RProcess process; CleanupClosePushL(process); User::LeaveIfError(process.Create(KTestProcGood, KNullDesC)); ResumeL(process); //Setup monitoring and instruct KTestProcGood to not rendevouz when restarted INFO_PRINTF1(_L("Going to request process monitoring")); CStartupProperties* prop = CStartupProperties::NewLC(KTestProcGood, KTestProcGoodNoRendevouz); prop->SetMonitored(ETrue); prop->SetStartupType(EStartProcess); prop->SetStartMethod(EWaitForStart); prop->SetNoOfRetries(1); prop->SetTimeout(100); prop->SetRecoveryParams(EIgnoreOnFailure, 0); //this is what we are testing MonitorL(process, *prop); CleanupStack::PopAndDestroy(prop); //Create a scheduler for callbacks CActiveScheduler* sched = new(ELeave) CActiveScheduler; CleanupStack::PushL(sched); CActiveScheduler::Install(sched); //Timed callback to stop the nested scheduler when we have allowed enough time for the recovery policy to execute CPeriodic* timer = CPeriodic::NewL(CActive::EPriorityStandard); CleanupStack::PushL(timer); const TInt delay = KThrottleTime + 5000000; //make sure delay allow all retries enough time to complete their timeouts timer->Start(delay, delay, TCallBack(CancelWait, this)); //Observer for OS restart iNotifier = CSaveNotifier::NewL(*this); //Kill process and wait throttletime + time for recovery policy to execute TEST(Exists(KTestProcGood)); process.Kill(KErrNone); TEST(EFalse == Exists(KTestProcGood)); TTime time; time.HomeTime(); INFO_PRINTF3(_L("Killed process at time %d:%d, going to sleep for KThrottleTime + 5 seconds."), time.DateTime().Minute(), time.DateTime().Second()); CActiveScheduler::Start(); // now wait until one of the callbacks occur timer->Cancel(); CleanupStack::PopAndDestroy(timer); CleanupStack::PopAndDestroy(sched); CleanupStack::PopAndDestroy(&process); //Assert the process isn't there i.e. that the failure to restart KTestProcGood was ignored. INFO_PRINTF1(_L("Going to assert that the process failed to restart.")); const TBool running = Exists(KTestProcGood); TEST(EFalse == running); if(!running) { INFO_PRINTF1(_L("Process not running.")); } INFO_PRINTF1(_L("Test complete.")); return TestStepResult(); }
void TGLControl::ConstructL(const TRect&) { iOpenGlInitialized = EFalse; CreateWindowL(); SetExtentToWholeScreen(); ActivateL(); iFrame = 0; EGLConfig Config; iEglDisplay = eglGetDisplay( EGL_DEFAULT_DISPLAY ); if ( iEglDisplay == NULL ) { _LIT(KGetDisplayFailed, "eglGetDisplay failed"); User::Panic( KGetDisplayFailed, 0 ); } if ( eglInitialize( iEglDisplay, NULL, NULL ) == EGL_FALSE ) { _LIT(KInitializeFailed, "eglInitialize failed"); User::Panic( KInitializeFailed, 0 ); } EGLConfig *configList = NULL; // Pointer for EGLConfigs EGLint numOfConfigs = 0; EGLint configSize = 0; if ( eglGetConfigs( iEglDisplay, configList, configSize, &numOfConfigs ) == EGL_FALSE ) { _LIT(KGetConfigsFailed, "eglGetConfigs failed"); User::Panic( KGetConfigsFailed, 0 ); } configSize = numOfConfigs; configList = (EGLConfig*) User::Alloc( sizeof(EGLConfig)*configSize ); if ( configList == NULL ) { _LIT(KConfigAllocFailed, "config alloc failed"); User::Panic( KConfigAllocFailed, 0 ); } TDisplayMode DMode = Window().DisplayMode(); TInt BufferSize = 0; switch(DMode) { case EColor4K: BufferSize = 12; break; case EColor64K: BufferSize = 16; break; case EColor16M: BufferSize = 24; break; case EColor16MU: BufferSize = 32; break; default: _LIT(KDModeError, "unsupported displaymode"); User::Panic( KDModeError, 0 ); break; } const EGLint attrib_list[] = { EGL_BUFFER_SIZE, BufferSize, EGL_NONE }; if(eglChooseConfig( iEglDisplay, attrib_list, configList, configSize, &numOfConfigs ) == EGL_FALSE ) { _LIT(KChooseConfigFailed, "eglChooseConfig failed"); User::Panic( KChooseConfigFailed, 0 ); } Config = configList[0]; User::Free( configList ); iEglSurface = eglCreateWindowSurface( iEglDisplay, Config, &Window(), NULL ); if(iEglSurface == NULL) { _LIT(KCreateWindowSurfaceFailed, "eglCreateWindowSurface failed"); User::Panic( KCreateWindowSurfaceFailed, 0 ); } iEglContext = eglCreateContext( iEglDisplay, Config, EGL_NO_CONTEXT, NULL ); if(iEglContext == NULL) { _LIT(KCreateContextFailed, "eglCreateContext failed"); User::Panic( KCreateContextFailed, 0 ); } if(eglMakeCurrent( iEglDisplay, iEglSurface, iEglSurface, iEglContext ) == EGL_FALSE ) { _LIT(KMakeCurrentFailed, "eglMakeCurrent failed"); User::Panic( KMakeCurrentFailed, 0 ); } TSize size; size = this->Size(); scene = new (ELeave) TGLScene(size.iWidth, size.iHeight); scene->AppInit(); iOpenGlInitialized = ETrue; iPeriodic = CPeriodic::NewL( CActive::EPriorityIdle ); iPeriodic->Start( 100, 100, TCallBack( TGLControl::DrawCallBack, this ) ); }