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: a07f3367d7,5cc10500d0b7a280 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!goblin1!goblin.stu.neva.ru!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!bnewspeer01.bru.ops.eu.uu.net!bnewspeer00.bru.ops.eu.uu.net!emea.uu.net!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: task model Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.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: <04458a0b-1e58-478b-a2f0-c47226f840ac@f16g2000yqm.googlegroups.com> <6b6bd661-06b0-4ef6-8d48-0ef97d55fdd4@f20g2000prn.googlegroups.com> Date: Thu, 15 Oct 2009 21:54:27 +0200 Message-ID: NNTP-Posting-Date: 15 Oct 2009 21:54:23 CEST NNTP-Posting-Host: a4583285.newsspool4.arcor-online.net X-Trace: DXC=iajKcmk`>6j[F<50eo:0kn4IUK On Thu, 15 Oct 2009 12:15:56 -0700 (PDT), Anh Vo wrote: > I would like to expand Ludovic's comment. > > You have a couple of options to improve it. > > 1. Make sure the task not terminated before calling its entry. That is > using proc1'terminated syntax to query it. > 2. Add infinite loop enclosing accept statements. So, entry call can > be served always. This makes tasks alive even after the program ends > (program will hang) unless Ctrl-C or other mean to end it. The clean > solution is add entry Shutdown to the task. When this entry is > invoked, just exit the loop. Thus, the task will terminate cleanly. 2'. In order to terminate a task upon parent's completion use select statement with a terminate alternative: select accept XYZ; or terminate; -- Ends the task when the parent terminates end select; (Shutdown entry is used when terminate is not allowed, e.g. when a delay alternative or else part is present in the select, or when some explicit completion code need to be executed, however any local objects are properly finalized when the terminate alternative is accepted.) 3. Do not do any asynchronous (lengthy) processing within a rendezvous, i.e. within do...end of an accept. During the rendezvous the caller is blocked. Rendezvous is meant for short synchronous things, like passing the parameters and results, then the caller is released and the callee completes things asynchronously to the caller. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de