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
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>AARM95 - Asynchronous Transfer of Control</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-7-3.html">Previous</A> <A HREF="AA-9-8.html">Next</A></P>
<HR>
<H1> 9.7.4 Asynchronous Transfer of Control</H1>
<DIV Class="Paranum"><FONT SIZE=-2>1</FONT></DIV>
<DIV Class="Normal"> [An asynchronous <FONT FACE="Arial, Helvetica">select_statement</FONT>
provides asynchronous transfer of control upon completion of an entry
call or the expiration of a delay.] </DIV>
<H4 ALIGN=CENTER>Syntax</H4>
<DIV Class="Paranum"><FONT SIZE=-2>2</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">asynchronous_select<A NAME="I3782"></A>
::= </FONT><BR>
<B>select</B><BR>
<A NAME="I3783"></A><FONT FACE="Arial, Helvetica">triggering_alternative</FONT><BR>
<B>then abort</B><BR>
<A NAME="I3784"></A><FONT FACE="Arial, Helvetica">abortable_part</FONT><BR>
<B>end select</B>;</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>3</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">triggering_alternative<A NAME="I3785"></A>
::= </FONT><A NAME="I3786"></A><FONT FACE="Arial, Helvetica">triggering_statement</FONT> [<A NAME="I3787"></A><FONT FACE="Arial, Helvetica">sequence_of_statements</FONT>]</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>4</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">triggering_statement<A NAME="I3788"></A>
::= </FONT><A NAME="I3789"></A><FONT FACE="Arial, Helvetica">entry_call_statement</FONT> | <A NAME="I3790"></A><FONT FACE="Arial, Helvetica">delay_statement</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>5</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">abortable_part<A NAME="I3791"></A>
::= </FONT><A NAME="I3792"></A><FONT FACE="Arial, Helvetica">sequence_of_statements</FONT></DIV>
<H4 ALIGN=CENTER>Dynamic Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>6</FONT></DIV>
<DIV Class="Normal"> <A NAME="I3793"></A>For the execution of an <FONT FACE="Arial, Helvetica">asynchronous_select</FONT>
whose <FONT FACE="Arial, Helvetica">triggering_statement</FONT> is an
<FONT FACE="Arial, Helvetica">entry_call_statement</FONT>, the <I>entry_</I><FONT FACE="Arial, Helvetica">name</FONT>
and actual parameters are evaluated as for a simple entry call (see <A HREF="AA-9-5-3.html">9.5.3</A>),
and the entry call is issued. If the entry call is queued (or requeued-with-abort),
then the <FONT FACE="Arial, Helvetica">abortable_part</FONT> is executed.
[If the entry call is selected immediately, and never requeued-with-abort,
then the <FONT FACE="Arial, Helvetica">abortable_part</FONT> is never
started.]</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7</FONT></DIV>
<DIV Class="Normal"> <A NAME="I3794"></A>For the execution of an <FONT FACE="Arial, Helvetica">asynchronous_select</FONT>
whose <FONT FACE="Arial, Helvetica">triggering_statement</FONT> is a
<FONT FACE="Arial, Helvetica">delay_statement</FONT>, the <I>delay_</I><FONT FACE="Arial, Helvetica">expression</FONT>
is evaluated and the expiration time is determined, as for a normal <FONT FACE="Arial, Helvetica">delay_statement</FONT>.
If the expiration time has not already passed, the <FONT FACE="Arial, Helvetica">abortable_part</FONT>
is executed.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8</FONT></DIV>
<DIV Class="Normal"> If the <FONT FACE="Arial, Helvetica">abortable_part</FONT>
completes and is left prior to completion of the <FONT FACE="Arial, Helvetica">triggering_statement</FONT>,
an attempt to cancel the <FONT FACE="Arial, Helvetica">triggering_statement</FONT>
is made. If the attempt to cancel succeeds (see <A HREF="AA-9-5-3.html">9.5.3</A>
and <A HREF="AA-9-6.html">9.6</A>), the <FONT FACE="Arial, Helvetica">asynchronous_select</FONT>
is complete.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>9</FONT></DIV>
<DIV Class="Normal"> If the <FONT FACE="Arial, Helvetica">triggering_statement</FONT>
completes other than due to cancellation, the <FONT FACE="Arial, Helvetica">abortable_part</FONT>
is aborted (if started but not yet completed -- see <A HREF="AA-9-8.html">9.8</A>).
If the <FONT FACE="Arial, Helvetica">triggering_statement</FONT> completes
normally, the optional <FONT FACE="Arial, Helvetica">sequence_of_statements</FONT>
of the <FONT FACE="Arial, Helvetica">triggering_alternative</FONT> is
executed after the <FONT FACE="Arial, Helvetica">abortable_part</FONT>
is left. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>9.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Discussion: </B>We currently
don't specify when the by-copy [<B>in</B>] <B>out</B> parameters are
assigned back into the actuals. We considered requiring that to happen
after the <FONT FACE="Arial, Helvetica">abortable_part</FONT> is left.
However, that doesn't seem useful enough to justify possibly overspecifying
the implementation approach, since some of the parameters are passed
by reference anyway.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>9.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>In an earlier description, we
required that the <FONT FACE="Arial, Helvetica">sequence_of_statements</FONT>
of the <FONT FACE="Arial, Helvetica">triggering_alternative</FONT> execute
after aborting the <FONT FACE="Arial, Helvetica">abortable_part</FONT>,
but before waiting for it to complete and finalize, to provide more rapid
response to the triggering event in case the finalization was unbounded.
However, various reviewers felt that this created unnecessary complexity
in the description, and a potential for undesirable concurrency (and
nondeterminism) within a single task. We have now reverted to simpler,
more deterministic semantics, but anticipate that further discussion
of this issue might be appropriate during subsequent reviews. One possibility
is to leave this area implementation defined, so as to encourage experimentation.
The user would then have to assume the worst about what kinds of actions
are appropriate for the <FONT FACE="Arial, Helvetica">sequence_of_statements</FONT>
of the <FONT FACE="Arial, Helvetica">triggering_alternative</FONT> to
achieve portability. </FONT></DIV>
<H4 ALIGN=CENTER>Examples</H4>
<DIV Class="Paranum"><FONT SIZE=-2>10</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em"> <A NAME="I3795"></A><A NAME="I3796"></A><A NAME="I3797"></A><I>Example
of a main command loop for a command interpreter:</I> </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11</FONT></DIV>
<DIV Class="Examples"><TT><B>loop</B><BR>
<B>select</B><BR>
Terminal.Wait_For_Interrupt;<BR>
Put_Line("Interrupted");<BR>
<B>then abort</B><BR>
-- <I>This will be abandoned upon terminal interrupt</I><BR>
Put_Line("-> ");<BR>
Get_Line(Command, Last);<BR>
Process_Command(Command(1..Last));<BR>
<B>end</B> <B>select</B>;<BR>
<B>end</B> <B>loop</B>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>12</FONT></DIV>
<DIV Class="Wide" Style="margin-bottom: 0.4em"> <I>Example of a time-limited
calculation:</I> <A NAME="I3798"></A><A NAME="I3799"></A><A NAME="I3800"></A><A NAME="I3801"></A><A NAME="I3802"></A></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>13</FONT></DIV>
<DIV Class="Examples"><TT><B>select</B><BR>
<B>delay</B> 5.0;<BR>
Put_Line("Calculation does not converge");<BR>
<B>then abort</B><BR>
-- <I>This calculation should finish in 5.0 seconds;</I><BR>
-- <I> if not, it is assumed to diverge.</I><BR>
Horribly_Complicated_Recursive_Function(X, Y);<BR>
<B>end</B> <B>select</B>;</TT></DIV>
<H4 ALIGN=CENTER>Extensions to Ada 83</H4>
<DIV Class="Paranum"><FONT SIZE=-2>13.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><A NAME="I3803"></A><FONT FACE="Arial, Helvetica">Asynchronous_select</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-7-3.html">Previous</A> <A HREF="AA-9-8.html">Next</A> <A HREF="AA-TTL.html">Legal</A></P>
</BODY>
</HTML>
|