1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>AARM95 - Delay Statements, Duration, and Time</TITLE>
<META NAME="Author" CONTENT="JTC1/SC22/WG9/ARG, by Randall Brukardt, ARG Editor">
<META NAME="GENERATOR" CONTENT="Arm_Form.Exe, Ada Reference Manual generator">
<STYLE type="text/css">
DIV.paranum {position: absolute; font-family: Arial, Helvetica, sans-serif; left: 0.5 em; top: auto}
TT {font-family: "Courier New", monospace}
DT {display: compact}
DIV.Normal {font-family: "Times New Roman", Times, serif; margin-bottom: 0.6em}
DIV.Wide {font-family: "Times New Roman", Times, serif; margin-top: 0.6em; margin-bottom: 0.6em}
DIV.Annotations {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-bottom: 0.6em}
DIV.WideAnnotations {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0.6em; margin-bottom: 0.6em}
DIV.Index {font-family: "Times New Roman", Times, serif}
DIV.SyntaxSummary {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.4em}
DIV.Notes {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.6em}
DIV.NotesHeader {font-family: "Times New Roman", Times, serif; margin-left: 2.0em}
DIV.SyntaxIndented {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.4em}
DIV.Indented {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-bottom: 0.6em}
DIV.CodeIndented {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-bottom: 0.6em}
DIV.SmallIndented {font-family: "Times New Roman", Times, serif; margin-left: 10.0em; margin-bottom: 0.6em}
DIV.SmallCodeIndented {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-bottom: 0.6em}
DIV.Examples {font-family: "Courier New", monospace; margin-left: 2.0em; margin-bottom: 0.6em}
DIV.SmallExamples {font-family: "Courier New", monospace; font-size: 80%; margin-left: 7.5em; margin-bottom: 0.6em}
DIV.IndentedExamples {font-family: "Courier New", monospace; margin-left: 8.0em; margin-bottom: 0.6em}
DIV.SmallIndentedExamples {font-family: "Courier New", monospace; font-size: 80%; margin-left: 15.0em; margin-bottom: 0.6em}
UL.Bulleted {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SmallBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SmallNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.IndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.CodeIndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.CodeIndentedNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SyntaxIndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NotesBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NotesNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
DL.Hanging {font-family: "Times New Roman", Times, serif; margin-top: 0em; margin-bottom: 0.6em}
DD.Hanging {margin-left: 6.0em}
DL.IndentedHanging {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.IndentedHanging {margin-left: 2.0em}
DL.HangingInBulleted {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.HangingInBulleted {margin-left: 4.0em}
DL.SmallHanging {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.SmallHanging {margin-left: 7.5em}
DL.SmallIndentedHanging {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.SmallIndentedHanging {margin-left: 2.0em}
DL.SmallHangingInBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.SmallHangingInBulleted {margin-left: 5.0em}
DL.Enumerated {font-family: "Times New Roman", Times, serif; margin-right: 0.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.Enumerated {margin-left: 2.0em}
DL.SmallEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.SmallEnumerated {margin-left: 2.5em}
DL.NestedEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
DL.SmallNestedEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
</STYLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFF0" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">
<P><A HREF="AA-TOC.html">Contents</A> <A HREF="AA-0-29.html">Index</A> <A HREF="AA-9-5-4.html">Previous</A> <A HREF="AA-9-7.html">Next</A></P>
<HR>
<H1> 9.6 Delay Statements, Duration, and Time</H1>
<DIV Class="Paranum"><FONT SIZE=-2>1</FONT></DIV>
<DIV Class="Normal"> [<A NAME="I3689"></A> A <FONT FACE="Arial, Helvetica">delay_statement</FONT>
is used to block further execution until a specified <I>expiration time</I>
is reached. The expiration time can be specified either as a particular
point in time (in a <FONT FACE="Arial, Helvetica">delay_until_statement</FONT>),
or in seconds from the current time (in a <FONT FACE="Arial, Helvetica">delay_relative_statement</FONT>).
The language-defined package Calendar provides definitions for a type
Time and associated operations, including a function Clock that returns
the current time. <A NAME="I3690"></A>]</DIV>
<H4 ALIGN=CENTER>Syntax</H4>
<DIV Class="Paranum"><FONT SIZE=-2>2</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">delay_statement<A NAME="I3691"></A>
::= </FONT><A NAME="I3692"></A><FONT FACE="Arial, Helvetica">delay_until_statement</FONT> | <A NAME="I3693"></A><FONT FACE="Arial, Helvetica">delay_relative_statement</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>3</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">delay_until_statement<A NAME="I3694"></A>
::= </FONT><B>delay until</B> <I>delay_</I><A NAME="I3695"></A><FONT FACE="Arial, Helvetica">expression</FONT>;</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>4</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">delay_relative_statement<A NAME="I3696"></A>
::= </FONT><B>delay</B> <I>delay_</I><A NAME="I3697"></A><FONT FACE="Arial, Helvetica">expression</FONT>;</DIV>
<H4 ALIGN=CENTER>Name Resolution Rules</H4>
<DIV Class="Paranum"><FONT SIZE=-2>5</FONT></DIV>
<DIV Class="Normal"> <A NAME="I3698"></A>The expected type for the
<I>delay_</I><FONT FACE="Arial, Helvetica">expression</FONT> in a <FONT FACE="Arial, Helvetica">delay_relative_statement</FONT>
is the predefined type Duration. <A NAME="I3699"></A>The <I>delay_</I><FONT FACE="Arial, Helvetica">expression</FONT>
in a <FONT FACE="Arial, Helvetica">delay_until_statement</FONT> is expected
to be of any nonlimited type.</DIV>
<H4 ALIGN=CENTER>Legality Rules</H4>
<DIV Class="Paranum"><FONT SIZE=-2>6</FONT></DIV>
<DIV Class="Normal"> <A NAME="I3700"></A><A NAME="I3701"></A><A NAME="I3702"></A>There
can be multiple time bases, each with a corresponding clock, and a corresponding
<I>time type</I>. The type of the <I>delay_</I><FONT FACE="Arial, Helvetica">expression</FONT>
in a <FONT FACE="Arial, Helvetica">delay_until_statement</FONT> shall
be a time type -- either the type Time defined in the language-defined
package Calendar (see below), or some other implementation-defined time
type (see <A HREF="AA-D-8.html">D.8</A>). </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>6.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Implementation defined: </B>Any
implementation-defined time types.</FONT></DIV>
<H4 ALIGN=CENTER>Static Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>7</FONT></DIV>
<DIV Class="Normal"> [There is a predefined fixed point type named
Duration, declared in the visible part of package Standard;] a value
of type Duration is used to represent the length of an interval of time,
expressed in seconds. [The type Duration is not specific to a particular
time base, but can be used with any time base.]</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8</FONT></DIV>
<DIV Class="Normal"> A value of the type Time in package Calendar,
or of some other implementation-defined time type, represents a time
as reported by a corresponding clock.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>9</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em"> The following language-defined
library package exists: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>10</FONT></DIV>
<DIV Class="Examples"><TT><A NAME="I3703"></A><A NAME="I3704"></A><A NAME="I3705"></A><BR>
<B>package</B> Ada.Calendar <B>is</B><BR>
<B>type</B> <A NAME="I3706"></A><A NAME="I3707"></A>Time <B>is</B> <B>private</B>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11</FONT></DIV>
<DIV Class="Examples"><TT> <B>subtype</B> <A NAME="I3708"></A>Year_Number <B>is</B> Integer <B>range</B> 1901 .. 2099;<BR>
<B>subtype</B> <A NAME="I3709"></A>Month_Number <B>is</B> Integer <B>range</B> 1 .. 12;<BR>
<B>subtype</B> <A NAME="I3710"></A>Day_Number <B>is</B> Integer <B>range</B> 1 .. 31;<BR>
<B>subtype</B> <A NAME="I3711"></A>Day_Duration <B>is</B> Duration <B>range</B> 0.0 .. 86_400.0;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>12</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I3712"></A><A NAME="I3713"></A>Clock <B>return</B> Time;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>13</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I3714"></A><A NAME="I3715"></A>Year (Date : Time) <B>return</B> Year_Number;<BR>
<B>function</B> <A NAME="I3716"></A><A NAME="I3717"></A>Month (Date : Time) <B>return</B> Month_Number;<BR>
<B>function</B> <A NAME="I3718"></A><A NAME="I3719"></A>Day (Date : Time) <B>return</B> Day_Number;<BR>
<B>function</B> <A NAME="I3720"></A><A NAME="I3721"></A>Seconds(Date : Time) <B>return</B> Day_Duration;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>14</FONT></DIV>
<DIV Class="Examples"><TT> <B>procedure</B> <A NAME="I3722"></A><A NAME="I3723"></A>Split (Date : <B>in</B> Time;<BR>
Year : <B>out</B> Year_Number;<BR>
Month : <B>out</B> Month_Number;<BR>
Day : <B>out</B> Day_Number;<BR>
Seconds : <B>out</B> Day_Duration);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>15</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I3724"></A><A NAME="I3725"></A>Time_Of(Year : Year_Number;<BR>
Month : Month_Number;<BR>
Day : Day_Number;<BR>
Seconds : Day_Duration := 0.0)<BR>
<B>return</B> Time;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>16</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> "+" (Left : Time; Right : Duration) <B>return</B> Time;<BR>
<B>function</B> "+" (Left : Duration; Right : Time) <B>return</B> Time;<BR>
<B>function</B> "-" (Left : Time; Right : Duration) <B>return</B> Time;<BR>
<B>function</B> "-" (Left : Time; Right : Time) <B>return</B> Duration;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>17</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> "<" (Left, Right : Time) <B>return</B> Boolean;<BR>
<B>function</B> "<="(Left, Right : Time) <B>return</B> Boolean;<BR>
<B>function</B> ">" (Left, Right : Time) <B>return</B> Boolean;<BR>
<B>function</B> ">="(Left, Right : Time) <B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>18</FONT></DIV>
<DIV Class="Examples"><TT> <A NAME="I3726"></A>Time_Error : <B>exception;</B></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>19</FONT></DIV>
<DIV Class="Examples"><TT><B>private</B><BR>
... -- <I>not specified by the language</I><BR>
<B>end</B> Ada.Calendar;</TT></DIV>
<H4 ALIGN=CENTER>Dynamic Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>20</FONT></DIV>
<DIV Class="Normal"> <A NAME="I3727"></A>For the execution of a <FONT FACE="Arial, Helvetica">delay_statement</FONT>,
the <I>delay_</I><FONT FACE="Arial, Helvetica">expression</FONT> is first
evaluated. <A NAME="I3728"></A>For a <FONT FACE="Arial, Helvetica">delay_until_statement</FONT>,
the expiration time for the delay is the value of the <I>delay_</I><FONT FACE="Arial, Helvetica">expression</FONT>,
in the time base associated with the type of the <FONT FACE="Arial, Helvetica">expression</FONT>.
<A NAME="I3729"></A>For a <FONT FACE="Arial, Helvetica">delay_relative_statement</FONT>,
the expiration time is defined as the current time, in the time base
associated with relative delays, plus the value of the <I>delay_</I><FONT FACE="Arial, Helvetica">expression</FONT>
converted to the type Duration, and then rounded up to the next clock
tick. <A NAME="I3730"></A>The time base associated with relative delays
is as defined in <A HREF="AA-D-9.html">D.9</A>, ``<A HREF="AA-D-9.html">Delay
Accuracy</A>'' or is implementation defined. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>20.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Implementation defined: </B>The
time base associated with relative delays.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>20.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>Rounding
up to the next clock tick means that the reading of the delay-relative
clock when the delay expires should be no less than the current reading
of the delay-relative clock plus the specified duration. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>21</FONT></DIV>
<DIV Class="Normal"> <A NAME="I3731"></A>The task executing a <FONT FACE="Arial, Helvetica">delay_statement</FONT>
is blocked until the expiration time is reached, at which point it becomes
ready again. If the expiration time has already passed, the task is not
blocked. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>21.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Discussion: </B>For a <FONT FACE="Arial, Helvetica">delay_relative_statement</FONT>,
this case corresponds to when the value of the <I>delay_</I><FONT FACE="Arial, Helvetica">expression</FONT>
is zero or negative.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>21.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>Even though the task is not blocked,
it might be put back on the end of its ready queue. See <A HREF="AA-D-2.html">D.2</A>,
``<A HREF="AA-D-2.html">Priority Scheduling</A>''. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>22</FONT></DIV>
<DIV Class="Normal"> <A NAME="I3732"></A>If an attempt is made to
<I>cancel</I> the <FONT FACE="Arial, Helvetica">delay_statement</FONT>
[(as part of an <FONT FACE="Arial, Helvetica">asynchronous_select</FONT>
or abort -- see <A HREF="AA-9-7-4.html">9.7.4</A> and <A HREF="AA-9-8.html">9.8</A>)],
the <FONT FACE="Arial, Helvetica">_statement</FONT> is cancelled if the
expiration time has not yet passed, thereby completing the <FONT FACE="Arial, Helvetica">delay_statement</FONT>.
</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>22.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>This is worded
this way so that in an <FONT FACE="Arial, Helvetica">asynchronous_select</FONT>
where the <FONT FACE="Arial, Helvetica">triggering_statement</FONT> is
a <FONT FACE="Arial, Helvetica">delay_statement</FONT>, an attempt to
cancel the delay when the <FONT FACE="Arial, Helvetica">abortable_part</FONT>
completes is ignored if the expiration time has already passed, in which
case the optional statements of the <FONT FACE="Arial, Helvetica">triggering_alternative</FONT>
are executed. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>23</FONT></DIV>
<DIV Class="Normal"> The time base associated with the type Time of
package Calendar is implementation defined. The function Clock of package
Calendar returns a value representing the current time for this time
base. [The implementation-defined value of the named number System.Tick
(see <A HREF="AA-13-7.html">13.7</A>) is an approximation of the length
of the real-time interval during which the value of Calendar.Clock remains
constant.] </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>23.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Implementation defined: </B>The
time base of the type Calendar.Time.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>24</FONT></DIV>
<DIV Class="Normal"> The functions Year, Month, Day, and Seconds return
the corresponding values for a given value of the type Time, as appropriate
to an implementation-defined timezone; the procedure Split returns all
four corresponding values. Conversely, the function Time_Of combines
a year number, a month number, a day number, and a duration, into a value
of type Time. The operators "+" and "-" for addition
and subtraction of times and durations, and the relational operators
for times, have the conventional meaning. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>24.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Implementation defined: </B>The
timezone used for package Calendar operations.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>25</FONT></DIV>
<DIV Class="Normal"> If Time_Of is called with a seconds value of
86_400.0, the value returned is equal to the value of Time_Of for the
next day with a seconds value of 0.0. The value returned by the function
Seconds or through the Seconds parameter of the procedure Split is always
less than 86_400.0.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>26/1</FONT></DIV>
<DIV Class="Normal"> {<I><A HREF="defect1.html#8652/0030">8652/0030</A></I>}
The exception Time_Error is raised by the function Time_Of if the actual
parameters do not form a proper date. This exception is also raised by
the operators "+" and "-" if the result is not representable
in the type Time or Duration, as appropriate. This exception is also
raised by the function<U>s</U> Year<U>, Month, Day, and Seconds and</U><S>or</S>
the procedure Split if the year number of the given date is outside of
the range of the subtype Year_Number. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>26.a/1</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>To be honest: </B>{<I><A HREF="defect2.html#8652/0106">8652/0106</A></I>}
By "proper date" above we mean that the given year has a month
with the given day. For example, February 29th is a proper date only
for a leap year. <U>We do not mean to include the Seconds in this notion;
in particular, we do not mean to require implementations to check for
the ``missing hour'' that occurs when Daylight Savings Time starts in
the spring.</U> </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>26.b/1</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>{<I><A HREF="defect1.html#8652/0030">8652/0030</A></I>}
We allow Year and Split to raise Time_Error because the arithmetic operators
are allowed (but not required) to produce times that are outside the
range of years from 1901 to 2099. This is similar to the way integer
operators may return values outside the base range of their type so long
as the value is mathematically correct. <U>We allow the functions Month,
Day and Seconds to raise Time_Error so that they can be implemented in
terms of Split.</U> </FONT></DIV>
<H4 ALIGN=CENTER>Implementation Requirements</H4>
<DIV Class="Paranum"><FONT SIZE=-2>27</FONT></DIV>
<DIV Class="Normal"> The implementation of the type Duration shall
allow representation of time intervals (both positive and negative) up
to at least 86400 seconds (one day); Duration'Small shall not be greater
than twenty milliseconds. The implementation of the type Time shall allow
representation of all dates with year numbers in the range of Year_Number[;
it may allow representation of other dates as well (both earlier and
later).] </DIV>
<H4 ALIGN=CENTER>Implementation Permissions</H4>
<DIV Class="Paranum"><FONT SIZE=-2>28</FONT></DIV>
<DIV Class="Normal"> An implementation may define additional time
types (see <A HREF="AA-D-8.html">D.8</A>).</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>29</FONT></DIV>
<DIV Class="Normal"> An implementation may raise Time_Error if the
value of a <I>delay_</I><FONT FACE="Arial, Helvetica">expression</FONT>
in a <FONT FACE="Arial, Helvetica">delay_until_statement</FONT> of a
<FONT FACE="Arial, Helvetica">select_statement</FONT> represents a time
more than 90 days past the current time. The actual limit, if any, is
implementation-defined. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>29.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Implementation defined: </B>Any
limit on <FONT FACE="Arial, Helvetica">delay_until_statement</FONT>s
of <FONT FACE="Arial, Helvetica">select_statement</FONT>s.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>29.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Implementation Note: </B>This
allows an implementation to implement <FONT FACE="Arial, Helvetica">select_statement</FONT>
timeouts using a representation that does not support the full range
of a time type. In particular 90 days of seconds can be represented in
23 bits, allowing a signed 24-bit representation for the seconds part
of a timeout. There is no similar restriction allowed for stand-alone
<FONT FACE="Arial, Helvetica">delay_until_statement</FONT>s, as these
can be implemented internally using a loop if necessary to accommodate
a long delay. </FONT></DIV>
<H4 ALIGN=CENTER>Implementation Advice</H4>
<DIV Class="Paranum"><FONT SIZE=-2>30</FONT></DIV>
<DIV Class="Normal"> Whenever possible in an implementation, the value
of Duration'Small should be no greater than 100 microseconds. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>30.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Implementation Note: </B>This
can be satisfied using a 32-bit 2's complement representation with a
<I>small</I> of 2.0**(-14) -- that is, 61 microseconds -- and a range
of ± 2.0**17 -- that is, 131_072.0. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>31</FONT></DIV>
<DIV Class="Normal"> The time base for <FONT FACE="Arial, Helvetica">delay_relative_statement</FONT>s
should be monotonic; it need not be the same time base as used for Calendar.Clock.</DIV>
<DIV Class="NotesHeader"><FONT SIZE=-1>NOTES</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>32</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>31 A <FONT FACE="Arial, Helvetica">delay_relative_statement</FONT>
with a negative value of the <I>delay_</I><FONT FACE="Arial, Helvetica">expression</FONT>
is equivalent to one with a zero value.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>33</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>32 A <FONT FACE="Arial, Helvetica">delay_statement</FONT>
may be executed by the environment task; consequently <FONT FACE="Arial, Helvetica">delay_statement</FONT>s
may be executed as part of the elaboration of a <FONT FACE="Arial, Helvetica">library_item</FONT>
or the execution of the main subprogram. Such statements delay the environment
task (see <A HREF="AA-10-2.html">10.2</A>).</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>34</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>33 <A NAME="I3733"></A><A NAME="I3734"></A>A
<FONT FACE="Arial, Helvetica">delay_statement</FONT> is an abort completion
point and a potentially blocking operation, even if the task is not actually
blocked.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>35</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>34 There is no necessary
relationship between System.Tick (the resolution of the clock of package
Calendar) and Duration'Small (the <I>small</I> of type Duration). </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>35.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>The inaccuracy
of the <FONT FACE="Arial, Helvetica">delay_statement</FONT> has no relation
to System.Tick. In particular, it is possible that the clock used for
the <FONT FACE="Arial, Helvetica">delay_statement</FONT> is less accurate
than Calendar.Clock.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>35.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>We considered making Tick a run-time-determined
quantity, to allow for easier configurability. However, this would not
be upward compatible, and the desired configurability can be achieved
using functionality defined in <A HREF="AA-D.html">Annex D</A>, ``<A HREF="AA-D.html">Real-Time
Systems</A>''. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>36</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>35 Additional requirements
associated with <FONT FACE="Arial, Helvetica">delay_statement</FONT>s
are given in <A HREF="AA-D-9.html">D.9</A>, ``<A HREF="AA-D-9.html">Delay
Accuracy</A>''.</FONT></DIV>
<H4 ALIGN=CENTER>Examples</H4>
<DIV Class="Paranum"><FONT SIZE=-2>37</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em"> <I>Example of a
relative delay statement:</I> </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>38</FONT></DIV>
<DIV Class="Examples"><TT><B>delay</B> 3.0; <I>-- delay 3.0 seconds</I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>39</FONT></DIV>
<DIV Class="Wide" Style="margin-bottom: 0.4em"> <A NAME="I3735"></A><A NAME="I3736"></A><I>Example
of a periodic task:</I> </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>40</FONT></DIV>
<DIV Class="Examples"><TT><B>declare</B><BR>
<B>use</B> Ada.Calendar;<BR>
Next_Time : Time := Clock + Period;<BR>
<I>-- Period is a global constant of type Duration</I><BR>
<B>begin</B><BR>
<B>loop</B> <I>-- repeated every Period seconds</I><BR>
<B>delay</B> <B>until</B> Next_Time;<BR>
... <I>-- perform some actions</I><BR>
Next_Time := Next_Time + Period;<BR>
<B>end</B> <B>loop;</B><BR>
<B>end;</B></TT></DIV>
<H4 ALIGN=CENTER>Inconsistencies With Ada 83</H4>
<DIV Class="Paranum"><FONT SIZE=-2>40.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><A NAME="I3737"></A>For programs
that raise Time_Error on "+" or "-" in Ada 83,the
exception might be deferred until a call on Split or Year_Number, or
might not be raised at all (if the offending time is never Split after
being calculated). This should not affect typical programs, since they
deal only with times corresponding to the relatively recent past or near
future. </FONT></DIV>
<H4 ALIGN=CENTER>Extensions to Ada 83</H4>
<DIV Class="Paranum"><FONT SIZE=-2>40.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><A NAME="I3738"></A>The syntax
rule for <FONT FACE="Arial, Helvetica">delay_statement</FONT> is modified
to allow <FONT FACE="Arial, Helvetica">delay_until_statement</FONT>s.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>40.c</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>The type Time may represent dates
with year numbers outside of Year_Number. Therefore, the operations "+"
and "-" need only raise Time_Error if the result is not representable
in Time (or Duration); also, Split or Year will now raise Time_Error
if the year number is outside of Year_Number. This change is intended
to simplify the implementation of "+" and "-" (allowing
them to depend on overflow for detecting when to raise Time_Error) and
to allow local timezone information to be considered at the time of Split
rather than Clock (depending on the implementation approach). For example,
in a POSIX environment, it is natural for the type Time to be based on
GMT, and the results of procedure Split (and the functions Year, Month,
Day, and Seconds) to depend on local time zone information. In other
environments, it is more natural for the type Time to be based on the
local time zone, with the results of Year, Month, Day, and Seconds being
pure functions of their input.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>40.d</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>We anticipate that implementations
will provide child packages of Calendar to provide more explicit control
over time zones and other environment-dependent time-related issues.
These would be appropriate for standardization in a given environment
(such as POSIX). </FONT></DIV>
<HR>
<P><A HREF="AA-TOC.html">Contents</A> <A HREF="AA-0-29.html">Index</A> <A HREF="AA-9-5-4.html">Previous</A> <A HREF="AA-9-7.html">Next</A> <A HREF="AA-TTL.html">Legal</A></P>
</BODY>
</HTML>
|