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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 2002:a24:fe05:: with SMTP id w5-v6mr2715610ith.14.1523870396090; Mon, 16 Apr 2018 02:19:56 -0700 (PDT) X-Received: by 2002:a9d:554a:: with SMTP id h10-v6mr608483oti.5.1523870395980; Mon, 16 Apr 2018 02:19:55 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!maths.tcd.ie!newsswitch.lcs.mit.edu!bloom-beacon.mit.edu!bloom-beacon.mit.edu!168.235.88.217.MISMATCH!feeder.erje.net!2.us.feeder.erje.net!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!e130-v6no2197020itb.0!news-out.google.com!u64-v6ni4179itb.0!nntp.google.com!e130-v6no2197019itb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 16 Apr 2018 02:19:55 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2003:c7:83e8:db12:696c:ad4f:4ab3:cb58; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf NNTP-Posting-Host: 2003:c7:83e8:db12:696c:ad4f:4ab3:cb58 References: <702e2422-a93f-4200-9749-5122c3d0f899@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Finalization of library level tasks From: AdaMagica Injection-Date: Mon, 16 Apr 2018 09:19:56 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 3242 X-Received-Body-CRC: 2884557529 Xref: reader02.eternal-september.org comp.lang.ada:51542 Date: 2018-04-16T02:19:55-07:00 List-Id: Am Sonntag, 15. April 2018 19:40:38 UTC+2 schrieb Dmitry A. Kazakov: > On 2018-04-15 19:17, AdaMagica wrote: > > task body Worker_Type is > > begin > > loop > > select > > accept Quit; > > exit; > > or > > terminate; > > end select; > > end loop; > > end Worker_Type; > >=20 > > procedure Finalize (X: in out T) is > > begin > > if X.Worker'Callable then > > X.Worker.Quit; > > end if; > > end Finalize; >=20 > This task will hang in the select statement. >=20 > Terminate alternative is almost always useless because it cannot be=20 > mixed with "else" or "delay". The only way to request the completion from outside a task is (if I remembe= r correctly) an abort statement. Then you don't need terminate. Terminate is designed for passive tasks (let's call them thus), which becom= e active only on request, i.e. via an entry call. Thus terminate, delay and= else-statement are mutually exclusive. (I'm sure you know all this well.) = Terminate is called by (hm, dunno, a task supervisor) when it is clear that= there are no more clients who can call any of the entries, so the task has= nothing more to do. A delay or else-statement would be a contradiction. Thus your design seems wrong if you need something like this. > If there were a way to check within the=20 > task if its completion has been requested your solution would work.=20 > Terminate should have been a normal predefined entry: >=20 > task body T is > begin > select > accept T'Terminate; > exit; > or ... This would lead to a very different tasking feature - a completely differen= t Ada you every now and then seem to propose.