|
1 // Copyright (c) 1997-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 // One-shot timer mixin |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 */ |
|
21 |
|
22 |
|
23 #include <nifutl.h> |
|
24 #include "NI_STD.H" |
|
25 |
|
26 NONSHARABLE_CLASS(COneShotTimer) : public CTimer |
|
27 /** |
|
28 @internalComponent |
|
29 */ |
|
30 { |
|
31 public: |
|
32 COneShotTimer(MTimer* aTimer, TInt aPriority); |
|
33 void ConstructL(); |
|
34 virtual void RunL(); |
|
35 private: |
|
36 MTimer *iTimer; |
|
37 }; |
|
38 |
|
39 #if !defined(__EABI__) && !defined(__X86GCC__) |
|
40 EXPORT_C MTimer::MTimer() |
|
41 : iTimer(NULL) |
|
42 /** |
|
43 Constructor |
|
44 */ |
|
45 { |
|
46 } |
|
47 #endif |
|
48 |
|
49 EXPORT_C void MTimer::TimerDelete() |
|
50 { |
|
51 delete iTimer; |
|
52 iTimer=NULL; |
|
53 } |
|
54 |
|
55 EXPORT_C void MTimer::TimerConstructL(TInt aPriority) |
|
56 { |
|
57 iTimer = new (ELeave) COneShotTimer(this, aPriority); |
|
58 ((COneShotTimer*)iTimer)->ConstructL(); |
|
59 } |
|
60 |
|
61 EXPORT_C void MTimer::TimerAt(const TTime& aTime) |
|
62 { |
|
63 __ASSERT_DEBUG(iTimer!=NULL, NetUtilPanic(ENuPanic_NotConstructed)); |
|
64 iTimer->At(aTime); |
|
65 } |
|
66 |
|
67 EXPORT_C void MTimer::TimerAfter(TTimeIntervalMicroSeconds32 aInterval) |
|
68 { |
|
69 __ASSERT_DEBUG(iTimer!=NULL, NetUtilPanic(ENuPanic_NotConstructed)); |
|
70 iTimer->After(aInterval); |
|
71 } |
|
72 |
|
73 EXPORT_C void MTimer::TimerLock(TTimerLockSpec aLock) |
|
74 { |
|
75 __ASSERT_DEBUG(iTimer!=NULL, NetUtilPanic(ENuPanic_NotConstructed)); |
|
76 iTimer->Lock(aLock); |
|
77 } |
|
78 |
|
79 EXPORT_C void MTimer::TimerCancel() |
|
80 { |
|
81 if (iTimer!=NULL) |
|
82 iTimer->Cancel(); |
|
83 } |
|
84 |
|
85 COneShotTimer::COneShotTimer(MTimer* aTimer, TInt aPriority) |
|
86 : CTimer(aPriority), iTimer(aTimer) |
|
87 /** |
|
88 Constructor |
|
89 */ |
|
90 { |
|
91 CActiveScheduler::Add(this); |
|
92 } |
|
93 |
|
94 void COneShotTimer::RunL() |
|
95 { |
|
96 iTimer->TimerComplete(iStatus.Int()); |
|
97 } |
|
98 |
|
99 void COneShotTimer::ConstructL() |
|
100 { |
|
101 CTimer::ConstructL(); |
|
102 } |