|
1 // Copyright (c) 2007-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 "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 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @internalComponent |
|
19 */ |
|
20 |
|
21 #include "renderertimer.h" |
|
22 #include "rendererrelay.h" |
|
23 #include "rendererutil.h" |
|
24 |
|
25 /** C++ constructor */ |
|
26 CRendererTimer::CRendererTimer(CRendererRelay& aRenderer) |
|
27 : CTimer(EPriorityHigh), iRenderer(aRenderer) |
|
28 { |
|
29 CActiveScheduler::Add(this); |
|
30 } |
|
31 |
|
32 /** Two-phased constructor. */ |
|
33 CRendererTimer* CRendererTimer::NewL(CRendererRelay& aRenderer) |
|
34 { |
|
35 CRendererTimer* self = new (ELeave) CRendererTimer(aRenderer); |
|
36 CleanupStack::PushL(self); |
|
37 self->ConstructL(); // this call CTimer::ConstructL |
|
38 CleanupStack::Pop(self); |
|
39 return self; |
|
40 } |
|
41 |
|
42 /** Destructor */ |
|
43 CRendererTimer::~CRendererTimer() |
|
44 { |
|
45 // cancel is called by CTimer destructor |
|
46 } |
|
47 |
|
48 /** Start the renderer timer */ |
|
49 void CRendererTimer::Start(TTimeIntervalMicroSeconds32 aDelay) |
|
50 { |
|
51 DEBUGPRINT2(_L("CRendererTimer::Start entered with aDelay=%d"), aDelay.Int()); |
|
52 |
|
53 __ASSERT_DEBUG(iRenderer.UpdateSubmitted() == EFalse, User::Panic(_L("CRT::Start"), KErrArgument)); |
|
54 __ASSERT_DEBUG(IsActive() == EFalse, User::Panic(_L("CRT::Start"), KErrCorrupt)); |
|
55 |
|
56 HighRes(aDelay); |
|
57 } |
|
58 |
|
59 /** Handle completion */ |
|
60 void CRendererTimer::RunL() |
|
61 { |
|
62 DEBUGPRINT2(_L("CRendererTimer::RunL entered with status=%d"), iStatus.Int()); |
|
63 |
|
64 if (iStatus == KErrNone) |
|
65 { |
|
66 iRenderer.RendererTimerExpired(); |
|
67 } |
|
68 } |
|
69 |
|
70 |
|
71 /** Two-phased constructor. */ |
|
72 CThreadUndertaker* CThreadUndertaker::NewL(RThread& aSubThread) |
|
73 { |
|
74 CThreadUndertaker* self; |
|
75 self = new (ELeave) CThreadUndertaker(aSubThread); |
|
76 return self; |
|
77 } |
|
78 |
|
79 /** Constructor for the class. */ |
|
80 CThreadUndertaker::CThreadUndertaker(RThread& aSubThread) |
|
81 : CActive(CActive::EPriorityIdle), iSubThread(aSubThread) |
|
82 { |
|
83 CActiveScheduler::Add(this); |
|
84 |
|
85 iStatus = KRequestPending; |
|
86 SetActive(); |
|
87 |
|
88 //Logon to the thread so we will receive signals |
|
89 iSubThread.Logon(iStatus); |
|
90 } |
|
91 |
|
92 /** Destructor for this class. */ |
|
93 CThreadUndertaker::~CThreadUndertaker() |
|
94 { |
|
95 Cancel(); |
|
96 } |
|
97 |
|
98 /** This function is triggered when the thread being monitored terminates. */ |
|
99 void CThreadUndertaker::RunL() |
|
100 { |
|
101 // If the thread being monitored panic, panic this thread. |
|
102 TInt reason = iSubThread.ExitReason(); |
|
103 TExitCategoryName category = iSubThread.ExitCategory(); |
|
104 User::Panic(category, reason); |
|
105 } |
|
106 |
|
107 /** Stop monitoring the thread for panics. */ |
|
108 void CThreadUndertaker::DoCancel() |
|
109 { |
|
110 iSubThread.LogonCancel(iStatus); |
|
111 } |