From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,3b69de4361f731f1 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.glorb.com!news.germany.com!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: ATC, an example please. Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1120121092.240284.285260@g14g2000cwa.googlegroups.com> Date: Thu, 30 Jun 2005 11:32:38 +0200 Message-ID: NNTP-Posting-Date: 30 Jun 2005 11:32:38 MEST NNTP-Posting-Host: 2e55edbc.newsread4.arcor-online.net X-Trace: DXC=6A0?=bQf=6T8f4>W>BJ_OP:ejgIfPPldTjW\KbG]kaMX]kI_X=5KeaVn68R8a4JIJQWRXZ37ga[7Zn919Q4_`VjYB8=X\UUgbkT X-Complaints-To: abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:11755 Date: 2005-06-30T11:32:38+02:00 List-Id: On 30 Jun 2005 01:44:52 -0700, e.coli wrote: > how ATC work? ATC transfers control, it does not abort any other task. This is why you have to explicitly kill the task. Another error in your code is that you wait not for the calculation completion, but for its initiation. > can you fix this example,please? Try this: with Ada.Text_Io; procedure Atc_Test is task A_Task is entry Start; entry Ready; end A_Task; task body A_Task is begin loop accept Start; Ada.Text_Io.Put_Line("one.start"); for Iteration in 1..100_0000 loop Ada.Text_Io.Put ("."); end loop; accept Ready; Ada.Text_Io.Put_Line("one.end"); end loop; end A_Task; begin A_Task.Start; -- Initiate calculation select delay 2.0; -- After time-out expiration, abort A_Task; -- kill the task! Ada.Text_Io.Put_Line ("Long calculation abandoned"); then abort A_Task.Ready; -- Wait for completion end select; Ada.Text_Io.Put_Line ("end main"); end Atc_Test; ---------------------- N.B. This is a wrong way to do things. Don't use ATC if you cannot prove that there is no other way. Don't abort task, which is even more brutal than ATC. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de