sl@0
|
1 |
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
/**
|
sl@0
|
17 |
@file
|
sl@0
|
18 |
@internalComponent
|
sl@0
|
19 |
*/
|
sl@0
|
20 |
|
sl@0
|
21 |
#include "renderertimer.h"
|
sl@0
|
22 |
#include "rendererrelay.h"
|
sl@0
|
23 |
#include "rendererutil.h"
|
sl@0
|
24 |
|
sl@0
|
25 |
/** C++ constructor */
|
sl@0
|
26 |
CRendererTimer::CRendererTimer(CRendererRelay& aRenderer)
|
sl@0
|
27 |
: CTimer(EPriorityHigh), iRenderer(aRenderer)
|
sl@0
|
28 |
{
|
sl@0
|
29 |
CActiveScheduler::Add(this);
|
sl@0
|
30 |
}
|
sl@0
|
31 |
|
sl@0
|
32 |
/** Two-phased constructor. */
|
sl@0
|
33 |
CRendererTimer* CRendererTimer::NewL(CRendererRelay& aRenderer)
|
sl@0
|
34 |
{
|
sl@0
|
35 |
CRendererTimer* self = new (ELeave) CRendererTimer(aRenderer);
|
sl@0
|
36 |
CleanupStack::PushL(self);
|
sl@0
|
37 |
self->ConstructL(); // this call CTimer::ConstructL
|
sl@0
|
38 |
CleanupStack::Pop(self);
|
sl@0
|
39 |
return self;
|
sl@0
|
40 |
}
|
sl@0
|
41 |
|
sl@0
|
42 |
/** Destructor */
|
sl@0
|
43 |
CRendererTimer::~CRendererTimer()
|
sl@0
|
44 |
{
|
sl@0
|
45 |
// cancel is called by CTimer destructor
|
sl@0
|
46 |
}
|
sl@0
|
47 |
|
sl@0
|
48 |
/** Start the renderer timer */
|
sl@0
|
49 |
void CRendererTimer::Start(TTimeIntervalMicroSeconds32 aDelay)
|
sl@0
|
50 |
{
|
sl@0
|
51 |
DEBUGPRINT2(_L("CRendererTimer::Start entered with aDelay=%d"), aDelay.Int());
|
sl@0
|
52 |
|
sl@0
|
53 |
__ASSERT_DEBUG(iRenderer.UpdateSubmitted() == EFalse, User::Panic(_L("CRT::Start"), KErrArgument));
|
sl@0
|
54 |
__ASSERT_DEBUG(IsActive() == EFalse, User::Panic(_L("CRT::Start"), KErrCorrupt));
|
sl@0
|
55 |
|
sl@0
|
56 |
HighRes(aDelay);
|
sl@0
|
57 |
}
|
sl@0
|
58 |
|
sl@0
|
59 |
/** Handle completion */
|
sl@0
|
60 |
void CRendererTimer::RunL()
|
sl@0
|
61 |
{
|
sl@0
|
62 |
DEBUGPRINT2(_L("CRendererTimer::RunL entered with status=%d"), iStatus.Int());
|
sl@0
|
63 |
|
sl@0
|
64 |
if (iStatus == KErrNone)
|
sl@0
|
65 |
{
|
sl@0
|
66 |
iRenderer.RendererTimerExpired();
|
sl@0
|
67 |
}
|
sl@0
|
68 |
}
|
sl@0
|
69 |
|
sl@0
|
70 |
|
sl@0
|
71 |
/** Two-phased constructor. */
|
sl@0
|
72 |
CThreadUndertaker* CThreadUndertaker::NewL(RThread& aSubThread)
|
sl@0
|
73 |
{
|
sl@0
|
74 |
CThreadUndertaker* self;
|
sl@0
|
75 |
self = new (ELeave) CThreadUndertaker(aSubThread);
|
sl@0
|
76 |
return self;
|
sl@0
|
77 |
}
|
sl@0
|
78 |
|
sl@0
|
79 |
/** Constructor for the class. */
|
sl@0
|
80 |
CThreadUndertaker::CThreadUndertaker(RThread& aSubThread)
|
sl@0
|
81 |
: CActive(CActive::EPriorityIdle), iSubThread(aSubThread)
|
sl@0
|
82 |
{
|
sl@0
|
83 |
CActiveScheduler::Add(this);
|
sl@0
|
84 |
|
sl@0
|
85 |
iStatus = KRequestPending;
|
sl@0
|
86 |
SetActive();
|
sl@0
|
87 |
|
sl@0
|
88 |
//Logon to the thread so we will receive signals
|
sl@0
|
89 |
iSubThread.Logon(iStatus);
|
sl@0
|
90 |
}
|
sl@0
|
91 |
|
sl@0
|
92 |
/** Destructor for this class. */
|
sl@0
|
93 |
CThreadUndertaker::~CThreadUndertaker()
|
sl@0
|
94 |
{
|
sl@0
|
95 |
Cancel();
|
sl@0
|
96 |
}
|
sl@0
|
97 |
|
sl@0
|
98 |
/** This function is triggered when the thread being monitored terminates. */
|
sl@0
|
99 |
void CThreadUndertaker::RunL()
|
sl@0
|
100 |
{
|
sl@0
|
101 |
// If the thread being monitored panic, panic this thread.
|
sl@0
|
102 |
TInt reason = iSubThread.ExitReason();
|
sl@0
|
103 |
TExitCategoryName category = iSubThread.ExitCategory();
|
sl@0
|
104 |
User::Panic(category, reason);
|
sl@0
|
105 |
}
|
sl@0
|
106 |
|
sl@0
|
107 |
/** Stop monitoring the thread for panics. */
|
sl@0
|
108 |
void CThreadUndertaker::DoCancel()
|
sl@0
|
109 |
{
|
sl@0
|
110 |
iSubThread.LogonCancel(iStatus);
|
sl@0
|
111 |
}
|