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,a0f8bfc88538cab5 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: task time-out&abort 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: <1119463703.048124.135330@o13g2000cwo.googlegroups.com> <1119521473.100930.133950@f14g2000cwb.googlegroups.com> Date: Thu, 23 Jun 2005 12:59:26 +0200 Message-ID: NNTP-Posting-Date: 23 Jun 2005 12:59:22 MEST NNTP-Posting-Host: 6732f07d.newsread2.arcor-online.net X-Trace: DXC=QdU9YKYW8SXYFAnNd=0_4TQ5U85hF6f;TjW\KbG]kaMXXSE8@R32 On 23 Jun 2005 03:11:13 -0700, e.coli wrote: > my goal is kill the task if the calculation is long more than 5 sec,. I would propose to use a more co-operative way than rather brutal aborting of a task (which is still possible, of course). What about this: with Ada.Text_IO; procedure Semplice2 is --processo genitore task Un_Task is entry Start; -- Starts calculation entry Drop_It; -- Aborts calculation entry Wait_For; -- Waits for the results end Un_Task; task body Un_Task is begin loop select accept Start; Ada.Text_Io.Put_Line ("Start"); for Iteration in 1..10_000 loop select accept Drop_It; goto Cancel; else delay 1.0; -- Doing things end select; end loop; accept Wait_For; <> null; or terminate; end select; end loop; end Un_Task; begin Un_Task.Start; Ada.Text_Io.Put_Line ("wait for a horribly long calculation"); select delay 5.0; un_task.Drop_It; Ada.Text_Io.Put_Line ("Horribly long calculation abandoned"); then abort un_task.Wait_For; Ada.Text_Io.Put_Line ("Horribly long calculation ready"); end select; end Semplice2; -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de