|
1 /* |
|
2 * Copyright (c) 2006-2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: CWait class implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "wait.h" |
|
20 |
|
21 // CONSTANTS |
|
22 |
|
23 _LIT( KPanicCat, "ActTimSche" ); |
|
24 |
|
25 enum TPanicReason |
|
26 { |
|
27 EAlreadyStarted |
|
28 }; |
|
29 |
|
30 LOCAL_C void Panic( TInt aCode ) |
|
31 { |
|
32 User::Panic( KPanicCat, aCode ); |
|
33 } |
|
34 |
|
35 // MEMBER FUNCTIONS |
|
36 |
|
37 CWait* CWait::NewL() |
|
38 { |
|
39 |
|
40 CWait* self = |
|
41 CWait::NewLC(); |
|
42 CleanupStack::Pop( self ); |
|
43 |
|
44 return self; |
|
45 } |
|
46 |
|
47 CWait* CWait::NewLC() |
|
48 { |
|
49 |
|
50 CWait* self = |
|
51 new( ELeave ) CWait; |
|
52 CleanupStack::PushL( self ); |
|
53 self->ConstructL(); |
|
54 |
|
55 return self; |
|
56 } |
|
57 |
|
58 CWait::CWait(): |
|
59 CTimer( EPriorityStandard ) |
|
60 { |
|
61 |
|
62 // Double check if base class adds active object into scheduler |
|
63 if( !IsAdded() ) |
|
64 { |
|
65 CActiveScheduler::Add( this ); |
|
66 } |
|
67 } |
|
68 |
|
69 void CWait::ConstructL() |
|
70 { |
|
71 |
|
72 // Do base constructions |
|
73 CTimer::ConstructL(); |
|
74 |
|
75 // Initialize active scheduler wait |
|
76 iWait = new( ELeave ) CActiveSchedulerWait; |
|
77 } |
|
78 |
|
79 // Destructor |
|
80 CWait::~CWait() |
|
81 { |
|
82 |
|
83 Cancel(); |
|
84 delete iWait; |
|
85 } |
|
86 |
|
87 // METHODS |
|
88 |
|
89 //----------------------------------------------------------------------------- |
|
90 // CWait::Start |
|
91 //----------------------------------------------------------------------------- |
|
92 // |
|
93 void CWait::Start( |
|
94 const TTimeIntervalMicroSeconds32& aInterval ) |
|
95 { |
|
96 |
|
97 __ASSERT_ALWAYS( !IsActive(), Panic( EAlreadyStarted ) ); |
|
98 |
|
99 After( aInterval ); |
|
100 iWait->Start(); |
|
101 } |
|
102 |
|
103 //----------------------------------------------------------------------------- |
|
104 // CWait::Stop |
|
105 //----------------------------------------------------------------------------- |
|
106 // |
|
107 void CWait::Stop() |
|
108 { |
|
109 |
|
110 Cancel(); |
|
111 } |
|
112 |
|
113 //----------------------------------------------------------------------------- |
|
114 // CWait::RunL |
|
115 //----------------------------------------------------------------------------- |
|
116 // |
|
117 void CWait::RunL() |
|
118 { |
|
119 |
|
120 // Double check that wait really started |
|
121 if( iWait->IsStarted() ) |
|
122 { |
|
123 iWait->AsyncStop(); |
|
124 } |
|
125 } |
|
126 |
|
127 //----------------------------------------------------------------------------- |
|
128 // CWait::DoCancel |
|
129 //----------------------------------------------------------------------------- |
|
130 // |
|
131 void CWait::DoCancel() |
|
132 { |
|
133 |
|
134 // Double check that wait really started |
|
135 CTimer::DoCancel(); |
|
136 if( iWait->IsStarted() ) |
|
137 { |
|
138 iWait->AsyncStop(); |
|
139 } |
|
140 } |
|
141 |
|
142 |
|
143 // end of file |