32
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 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:
|
|
15 |
* Flexible timer documentation's main page
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
/*
|
|
20 |
* %version: 1 %
|
|
21 |
*/
|
|
22 |
|
|
23 |
/**
|
|
24 |
@mainpage
|
|
25 |
|
|
26 |
@section mainGeneral General
|
|
27 |
|
|
28 |
Flexible timers are timers for synchronizing network access. This is achieved
|
|
29 |
by providing a timer service that instead of generating timeout at exact moment
|
|
30 |
of time, generates timeout within given window of time. This allows several
|
|
31 |
timeouts to be aligned, and only one wakeup is needed instead of many. This
|
|
32 |
improves battery life. The improvement depends on the used bearer and its
|
|
33 |
configuration.
|
|
34 |
|
|
35 |
Flexible timers are designed to provided similar API with existing Symbian
|
|
36 |
timers (RTimer, CTimer and CPeriodic), and (besides they extend the interfaces
|
|
37 |
by providing 64-bit interface for After(). I.e. using At() for longer than 35
|
|
38 |
minutes timers is not required.
|
|
39 |
|
|
40 |
@subsection mainYes When you should consider using Flexible timers
|
|
41 |
- If your timer can handle several minutes variation in expiration times @b AND
|
|
42 |
- If your timer is used to trigger network connectivity @b AND
|
|
43 |
- If your timer is long enough (> 5 min)
|
|
44 |
|
|
45 |
@subsection mainNo Who should NOT use Flexible timers
|
|
46 |
- If you need accurate timing (in resolution of minutes) @b OR
|
|
47 |
- If your timer is too rapid, i.e. less than 5 minutes @b OR
|
|
48 |
- If you need timeout when phone is powered off @b OR
|
|
49 |
- If you need reboot-proof timeouts
|
|
50 |
|
|
51 |
@section mainTimerWindow Concept
|
|
52 |
|
|
53 |
The main idea of flexible timer concept is that timers can expire @a early.
|
|
54 |
The time how much earlier timer can expire, is called @b timer @b expiration
|
|
55 |
@b window (or just window).
|
|
56 |
|
|
57 |
For example, a timer that is started to expire after 10 minutes timer that
|
|
58 |
window is configured to 2 minutes can expire at any time between 8 to 10
|
|
59 |
minutes. See the figure below.
|
|
60 |
|
|
61 |
\image html FlexTimerWindowConcept.png
|
|
62 |
|
|
63 |
There are two reasons when timer can expire:
|
|
64 |
-# The timer has reached the time it's set to be expired
|
|
65 |
-# Another timer is expiring within this timer's window
|
|
66 |
|
|
67 |
In picture below is shown two set of periodical timers; normal timers and
|
|
68 |
flexible timers. Each time a timer expires, it causes network access.
|
|
69 |
|
|
70 |
\image html FlexTimersExample.png
|
|
71 |
|
|
72 |
The picture also illustrates main differences between using normal and flexible
|
|
73 |
timers:
|
|
74 |
- number of network initializations decreases (12 vs. 6).
|
|
75 |
- timers are being "drifted" (e.g. interval of Timer 2 is actually 12 minutes)
|
|
76 |
|
|
77 |
@section mainArchitecture Architecture
|
|
78 |
|
|
79 |
In picture below is illustrated components of flexible timers.
|
|
80 |
|
|
81 |
\image html FlexTimerComponents.png
|
|
82 |
|
|
83 |
When a client uses flexible timers, the actual timer request is forwarded to
|
|
84 |
Flex Timer Server using Symbian's inter process communication (IPC). The
|
|
85 |
biggest difference to normal timers is that flexible timers actually are run in
|
|
86 |
different process than the client as the normal timers are run in local thread.
|
|
87 |
|
|
88 |
@section mainLimitations Limitations of flexible timers
|
|
89 |
|
|
90 |
@subsection mainTimerAccuracy Timer Accuracy
|
|
91 |
|
|
92 |
Although the timer can be set to expire in 1 microsecond accuracy, the actual
|
|
93 |
accuracy can vary from 1/64 second (one system tick) to 1 second. It depends
|
|
94 |
when the timer is set; timers are "rounded" to the next full second.
|
|
95 |
|
|
96 |
This implies that e.g. 1 microsecond periodic timer's period is 1 second; not
|
|
97 |
1 microsecond.
|
|
98 |
|
|
99 |
As the flexible timer's implementation relies on system ticks, it's possible
|
|
100 |
that the timer expires 1/64 second (one system tick) too early.
|
|
101 |
|
|
102 |
I.e. the timer can expire from -1/64 second to +1 second when it is set.
|
|
103 |
|
|
104 |
@note If timer accuracy at this resolution is concern for you, you should not
|
|
105 |
use flexible timers at all. Use normal timers instead.
|
|
106 |
|
|
107 |
@subsection mainMinValue Minimum timer value
|
|
108 |
|
|
109 |
The minimum timer value is 0 microsecond. Only exception is CFlexPeriodic's
|
|
110 |
interval that can be 1 microseconds.
|
|
111 |
|
|
112 |
@subsection mainMaxValue Maximum timer value
|
|
113 |
|
|
114 |
Maximum value for timer is 2 years (i.e. 730 days, 63072000 seconds).
|
|
115 |
|
|
116 |
@subsection mainMinWindow Minimum window value
|
|
117 |
|
|
118 |
The minimum value for timer window is zero microseconds.
|
|
119 |
|
|
120 |
@subsection mainMaxWindow Maximum window value
|
|
121 |
|
|
122 |
The maximum value for timer window is two years (i.e. 730 days, 63072000
|
|
123 |
seconds).
|
|
124 |
|
|
125 |
The default value for window is 20% of the timer's value (e.g. 10 minutes timer
|
|
126 |
has 2 minutes default window).
|
|
127 |
|
|
128 |
@subsection mainTimerDrifting Timer drifting
|
|
129 |
|
|
130 |
As the timer expiration can happen in timer expiration window, it usually
|
|
131 |
causes periodic timers to "drift".
|
|
132 |
|
|
133 |
For example:
|
|
134 |
|
|
135 |
@c CPeriodic is started at 8 o'clock with 30 minute interval.
|
|
136 |
It will then expire at 8.30, 9.00, ... 15.30, 16.00
|
|
137 |
|
|
138 |
If @c CFlexPeriodic is used as a timer it can possibly expire at
|
|
139 |
8.30, 9.00, 9.28, 9.55, ... 15.15, 15.42 etc.
|
|
140 |
|
|
141 |
@subsection mainReboot Reboot-proof
|
|
142 |
|
|
143 |
Flexible timers are @b not reboot-proof. I.e. after reboot all timers has to
|
|
144 |
be set again.
|
|
145 |
|
|
146 |
@section mainHowTo How to start using flexible timers
|
|
147 |
|
|
148 |
The flexible timer API is designed to be as similar to normal Symbian timers
|
|
149 |
as possible.
|
|
150 |
|
|
151 |
In the table below is described Symbian OS timer and its corresponding flexible
|
|
152 |
timer.
|
|
153 |
|
|
154 |
<table border=1 bordercolor="#84B0C7" cellspacing="0" align="center">
|
|
155 |
<tr><td><b>Symbian OS timer</b></td><td><b>Flexible timer</b></td></tr>
|
|
156 |
<tr><td><code>CPeriodic</code></td><td><code>CFlexPeriodic</code></td></tr>
|
|
157 |
<tr><td><code>CTimer</code></td><td><code>CFlexTimer</code></td></tr>
|
|
158 |
<tr><td><code>RTimer</code></td><td><code>RFlexTimer</code></td></tr>
|
|
159 |
</table>
|
|
160 |
|
|
161 |
Using of flexible timer is easy and fun. There are only three following steps;
|
|
162 |
|
|
163 |
-# Add following line to MMP-file
|
|
164 |
@code
|
|
165 |
LIBRARY flextimer.lib
|
|
166 |
@endcode
|
|
167 |
-# Include flexible timer's header to your code files, e.g. for periodic timer
|
|
168 |
@code
|
|
169 |
#include <flexperiodic.h>
|
|
170 |
@endcode
|
|
171 |
-# Convert the used Symbian OS timers to flexible timers, e.g.
|
|
172 |
@code
|
|
173 |
//Old: CPeriodic* myTimer = CPeriodic::NewL( CActive::EPriorityStandard );
|
|
174 |
CFlexPeriodic* myTimer = CFlexPeriodic::NewL( CActive::EPriorityStandard );
|
|
175 |
...
|
|
176 |
// By default the window is 20% of timer's values
|
|
177 |
myTimer->Start( myDelay, myInterval, myCallback ); // No changes
|
|
178 |
...
|
|
179 |
myTimer->Cancel(); // No changes
|
|
180 |
delete myTimer; // No changes
|
|
181 |
|
|
182 |
@endcode
|
|
183 |
|
|
184 |
More examples available in flexible timer's class documentation.
|
|
185 |
|
|
186 |
*/
|