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.1 required=5.0 tests=BAYES_00, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,4bd6ca8f7a1eb225 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Received: by 10.68.35.131 with SMTP id h3mr6083785pbj.1.1322093731521; Wed, 23 Nov 2011 16:15:31 -0800 (PST) MIME-Version: 1.0 Path: lh20ni10820pbb.0!nntp.google.com!news2.google.com!volia.net!news2.volia.net!feed-A.news.volia.net!news.musoftware.de!wum.musoftware.de!news.tornevall.net!news.jacob-sparre.dk!pnx.dk!jacob-sparre.dk!ada-dk.org!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Class with task destructor Date: Wed, 23 Nov 2011 18:15:24 -0600 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <30604696.94.1322013045135.JavaMail.geo-discussion-forums@yqzz20> <80027d05-2740-4899-b43a-514100ec9bd2@p16g2000yqd.googlegroups.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1322093728 19770 69.95.181.76 (24 Nov 2011 00:15:28 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 24 Nov 2011 00:15:28 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: news2.google.com comp.lang.ada:14582 Date: 2011-11-23T18:15:24-06:00 List-Id: "Adam Beneschan" wrote in message news:bf5f741b-8ced-4530-8090-df6d4e730a5e@e2g2000vbb.googlegroups.com... >On Nov 22, 9:04 pm, Yannick Duch�ne (Hibou57) wrote: >> Le Wed, 23 Nov 2011 03:44:39 +0100, Adam Beneschan a >> �crit:> The language rules say that Unchecked_Deallocation doesn't force >> tasks >> > to terminate. >> >> But it should, because unless I missed something, it seems in this >> example >> case at least, this lead to a dangling reference. > >*Any* use of Unchecked_Deallocation can lead to a dangling reference, >which is why it's called Unchecked. But also note that the language >explicitly says that if you use Unchecked_Deallocation on an object >that contains tasks, the object might not actually disappear >(13.11.2(9)). I'm not sure if there are language rules that say that >the object *must* not be deallocated immediately in a case like this, >where the task has a discriminant that refers to the object being >freed. I don't have time to look into it at the moment. Maybe >someone else knows? The task continues to run (always) through a UC. The compiler has to ensure that works, and if that means not deallocating the object, that would work. Janus/Ada doesn't work this way, all of the task information is in the TCB and there is no connection to the enclosing object. So we can deallocate it immediately - the task will still continue to work. TCBs are reused when the tasks terminate, and never before. The requirement that tasks continue to run means that putting a task directly in an object will typically lead to a language-required storage leak. I always suggest avoiding that. (All of my programs that use tasks use fixed pools of tasks that reset themselves after use, in large part because tasks can't be managed like other objects.) One could argue that this behavior is a bug in the Ada Standard (I've certainly said that in the past), but there are a number of technical reasons that doing something else would be problematical. And changing it now would definitely be incompatible - any program that depends on the task continuing to run would fail (and in the worst possible way - without any indication of the change). We tried to do something else for subpools, but the implementation costs were out of hand, and essentially we decided to punt (the behavior of tasks in subpools is unspecified) -- hoping to fix this somewhere down the line. Randy. -- Adam