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
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>AARM95 - Requeue Statements</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-3.html">Previous</A> <A HREF="AA-9-6.html">Next</A></P>
<HR>
<H1> 9.5.4 Requeue Statements</H1>
<DIV Class="Paranum"><FONT SIZE=-2>1</FONT></DIV>
<DIV Class="Normal"> [A <FONT FACE="Arial, Helvetica">requeue_statement</FONT>
can be used to complete an <FONT FACE="Arial, Helvetica">accept_statement</FONT>
or <FONT FACE="Arial, Helvetica">entry_body</FONT>, while redirecting
the corresponding entry call to a new (or the same) entry queue. <A NAME="I3674"></A>Such
a <I>requeue</I> can be performed with or without allowing an intermediate
cancellation of the call, due to an abort or the expiration of a delay.
<A NAME="I3675"></A><A NAME="I3676"></A>]</DIV>
<H4 ALIGN=CENTER>Syntax</H4>
<DIV Class="Paranum"><FONT SIZE=-2>2</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">requeue_statement<A NAME="I3677"></A>
::= </FONT><B>requeue</B> <I>entry_</I><A NAME="I3678"></A><FONT FACE="Arial, Helvetica">name</FONT> [<B>with</B> <B>abort</B>];</DIV>
<H4 ALIGN=CENTER>Name Resolution Rules</H4>
<DIV Class="Paranum"><FONT SIZE=-2>3</FONT></DIV>
<DIV Class="Normal"> <A NAME="I3679"></A>The <I>entry_</I><FONT FACE="Arial, Helvetica">name</FONT>
of a <FONT FACE="Arial, Helvetica">requeue_statement</FONT> shall resolve
to denote an entry (the <I>target entry</I>) that either has no parameters,
or that has a profile that is type conformant (see <A HREF="AA-6-3-1.html">6.3.1</A>)
with the profile of the innermost enclosing <FONT FACE="Arial, Helvetica">entry_body</FONT>
or <FONT FACE="Arial, Helvetica">accept_statement</FONT>. <A NAME="I3680"></A></DIV>
<H4 ALIGN=CENTER>Legality Rules</H4>
<DIV Class="Paranum"><FONT SIZE=-2>4</FONT></DIV>
<DIV Class="Normal"> A <FONT FACE="Arial, Helvetica">requeue_statement</FONT>
shall be within a callable construct that is either an <FONT FACE="Arial, Helvetica">entry_body</FONT>
or an <FONT FACE="Arial, Helvetica">accept_statement</FONT>, and this
construct shall be the innermost enclosing body or callable construct.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>5</FONT></DIV>
<DIV Class="Normal"> If the target entry has parameters, then its profile
shall be subtype conformant with the profile of the innermost enclosing
callable construct. <A NAME="I3681"></A></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>6</FONT></DIV>
<DIV Class="Normal"> <A NAME="I3682"></A>In a <FONT FACE="Arial, Helvetica">requeue_statement</FONT>
of an <FONT FACE="Arial, Helvetica">accept_statement</FONT> of some task
unit, either the target object shall be a part of a formal parameter
of the <FONT FACE="Arial, Helvetica">accept_statement</FONT>, or the
accessibility level of the target object shall not be equal to or statically
deeper than any enclosing <FONT FACE="Arial, Helvetica">accept_statement</FONT>
of the task unit. In a <FONT FACE="Arial, Helvetica">requeue_statement</FONT>
of an <FONT FACE="Arial, Helvetica">entry_body</FONT> of some protected
unit, either the target object shall be a part of a formal parameter
of the <FONT FACE="Arial, Helvetica">entry_body</FONT>, or the accessibility
level of the target object shall not be statically deeper than that of
the <FONT FACE="Arial, Helvetica">entry_declaration</FONT>.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>6.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>In the <FONT FACE="Arial, Helvetica">entry_body</FONT>
case, the intent is that the target object can be global, or can be a
component of the protected unit, but cannot be a local variable of the
<FONT FACE="Arial, Helvetica">entry_body</FONT>. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>6.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>These restrictions
ensure that the target object of the requeue outlives the completion
and finalization of the enclosing callable construct. They also prevent
requeuing from a nested <FONT FACE="Arial, Helvetica">accept_statement</FONT>
on a parameter of an outer <FONT FACE="Arial, Helvetica">accept_statement</FONT>,
which could create some strange "long-distance" connections
between an entry caller and its server.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>6.c</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>Note that in the strange case
where a <FONT FACE="Arial, Helvetica">task_body</FONT> is nested inside
an <FONT FACE="Arial, Helvetica">accept_statement</FONT>, it is permissible
to requeue from an <FONT FACE="Arial, Helvetica">accept_statement</FONT>
of the inner <FONT FACE="Arial, Helvetica">task_body</FONT> on parameters
of the outer <FONT FACE="Arial, Helvetica">accept_statement</FONT>. This
is not a problem because all calls on the inner task have to complete
before returning from the outer <FONT FACE="Arial, Helvetica">accept_statement</FONT>,
meaning no "dangling calls" will be created. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>6.d</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Implementation Note: </B>By
disallowing certain requeues, we ensure that the normal <FONT FACE="Arial, Helvetica">terminate_alternative</FONT>
rules remain sensible, and that explicit clearing of the entry queues
of a protected object during finalization is rarely necessary. In particular,
such clearing of the entry queues is necessary only (ignoring premature
Unchecked_Deallocation) for protected objects declared in a <FONT FACE="Arial, Helvetica">task_body</FONT>
(or created by an allocator for an access type declared in such a body)
containing one or more <FONT FACE="Arial, Helvetica">requeue_statement</FONT>s.
Protected objects declared in subprograms, or at the library level, will
never need to have their entry queues explicitly cleared during finalization.
</FONT></DIV>
<H4 ALIGN=CENTER>Dynamic Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>7</FONT></DIV>
<DIV Class="Normal"> <A NAME="I3683"></A>The execution of a <FONT FACE="Arial, Helvetica">requeue_statement</FONT>
proceeds by first evaluating the <I>entry_</I><FONT FACE="Arial, Helvetica">name</FONT>[,
including the <FONT FACE="Arial, Helvetica">prefix</FONT> identifying
the target task or protected object and the <FONT FACE="Arial, Helvetica">expression</FONT>
identifying the entry within an entry family, if any]. The <FONT FACE="Arial, Helvetica">entry_body</FONT>
or <FONT FACE="Arial, Helvetica">accept_statement</FONT> enclosing the
<FONT FACE="Arial, Helvetica">requeue_statement</FONT> is then completed[,
finalized, and left (see <A HREF="AA-7-6-1.html">7.6.1</A>)].</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8</FONT></DIV>
<DIV Class="Normal"> <A NAME="I3684"></A>For the execution of a requeue
on an entry of a target task, after leaving the enclosing callable construct,
the named entry is checked to see if it is open and the requeued call
is either selected immediately or queued, as for a normal entry call
(see <A HREF="AA-9-5-3.html">9.5.3</A>).</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>9</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em"> <A NAME="I3685"></A>For
the execution of a requeue on an entry of a target protected object,
after leaving the enclosing callable construct: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>10</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>if the requeue is an internal requeue (that is, the requeue
is back on an entry of the same protected object -- see <A HREF="AA-9-5.html">9.5</A>),
the call is added to the queue of the named entry and the ongoing protected
action continues (see <A HREF="AA-9-5-1.html">9.5.1</A>); </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>10.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>Note that
for an internal requeue, the call is queued without checking whether
the target entry is open. This is because the entry queues will be serviced
before the current protected action completes anyway, and considering
the requeued call immediately might allow it to "jump" ahead
of existing callers on the same queue. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>if the requeue is an external requeue (that is, the target
protected object is not implicitly the same as the current object --
see <A HREF="AA-9-5.html">9.5</A>), a protected action is started on
the target object and proceeds as for a normal entry call (see <A HREF="AA-9-5-3.html">9.5.3</A>).
</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>12</FONT></DIV>
<DIV Class="Normal"> If the new entry named in the <FONT FACE="Arial, Helvetica">requeue_statement</FONT>
has formal parameters, then during the execution of the <FONT FACE="Arial, Helvetica">accept_statement</FONT>
or <FONT FACE="Arial, Helvetica">entry_body</FONT> corresponding to the
new entry, the formal parameters denote the same objects as did the corresponding
formal parameters of the callable construct completed by the requeue.
[In any case, no parameters are specified in a <FONT FACE="Arial, Helvetica">requeue_statement</FONT>;
any parameter passing is implicit.]</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>13</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em"> <A NAME="I3686"></A>If
the <FONT FACE="Arial, Helvetica">requeue_statement</FONT> includes the
reserved words <B>with abort</B> (it is a <I>requeue-with-abort</I>),
then: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>14</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>if the original entry call has been aborted (see <A HREF="AA-9-8.html">9.8</A>),
then the requeue acts as an abort completion point for the call, and
the call is cancelled and no requeue is performed;</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>15</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>if the original entry call was timed (or conditional),
then the original expiration time is the expiration time for the requeued
call. </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>16</FONT></DIV>
<DIV Class="Normal"> If the reserved words <B>with abort</B> do not
appear, then the call remains protected against cancellation while queued
as the result of the <FONT FACE="Arial, Helvetica">requeue_statement</FONT>.
</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>16.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>This protection
against cancellation lasts only until the call completes or a subsequent
requeue-with-abort is performed on the call. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>16.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>We chose to protect
a requeue, by default, against abort or cancellation. This seemed safer,
since it is likely that extra steps need to be taken to allow for possible
cancellation once the servicing of an entry call has begun. This also
means that in the absence of <B>with abort</B> the usual Ada 83 behavior
is preserved, namely that once an entry call is accepted, it cannot be
cancelled until it completes. </FONT></DIV>
<DIV Class="NotesHeader"><FONT SIZE=-1>NOTES</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>17</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>30 A requeue is permitted
from a single entry to an entry of an entry family, or vice-versa. The
entry index, if any, plays no part in the subtype conformance check between
the profiles of the two entries; an entry index is part of the <I>entry_</I><FONT FACE="Arial, Helvetica">name</FONT>
for an entry of a family. <A NAME="I3687"></A></FONT></DIV>
<H4 ALIGN=CENTER>Examples</H4>
<DIV Class="Paranum"><FONT SIZE=-2>18</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em"> <I>Examples of
requeue statements:</I> </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>19</FONT></DIV>
<DIV Class="Examples"><TT><B>requeue</B> Request(Medium) <B>with abort</B>;<BR>
<I>-- requeue on a member of an entry family of the current task, see <A HREF="AA-9-1.html">9.1</A></I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>20</FONT></DIV>
<DIV Class="Examples"><TT><B>requeue</B> Flags(I).Seize;<BR>
<I>-- requeue on an entry of an array component, see <A HREF="AA-9-4.html">9.4</A></I></TT></DIV>
<H4 ALIGN=CENTER>Extensions to Ada 83</H4>
<DIV Class="Paranum"><FONT SIZE=-2>20.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><A NAME="I3688"></A>The <FONT FACE="Arial, Helvetica">requeue_statement</FONT>
is new. </FONT></DIV>
<HR>
<P><A HREF="AA-TOC.html">Contents</A> <A HREF="AA-0-29.html">Index</A> <A HREF="AA-9-5-3.html">Previous</A> <A HREF="AA-9-6.html">Next</A> <A HREF="AA-TTL.html">Legal</A></P>
</BODY>
</HTML>
|