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 autolearn=ham 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,UTF8 Received: by 10.68.15.41 with SMTP id u9mr2393957pbc.3.1322736719769; Thu, 01 Dec 2011 02:51:59 -0800 (PST) Path: lh20ni50716pbb.0!nntp.google.com!news1.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nx02.iad01.newshosting.com!newshosting.com!87.79.20.101.MISMATCH!newsreader4.netcologne.de!news.netcologne.de!news.swapon.de!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Class with task destructor Date: Thu, 01 Dec 2011 10:51:58 +0000 Organization: A noiseless patient Spider Message-ID: References: <30604696.94.1322013045135.JavaMail.geo-discussion-forums@yqzz20> <24938373.1788.1322615481874.JavaMail.geo-discussion-forums@yqjo5> Mime-Version: 1.0 Injection-Info: mx04.eternal-september.org; posting-host="dFCm8HWntFqmDIilBLqEJQ"; logging-data="16699"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19dwVe2EKD6hjLjVW90hnrkkqViNErUW4g=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (darwin) Cancel-Lock: sha1:DsyLdpaDO131+Nbs1VYxpLZUiZ4= sha1:OsL7UwYTDNErntEFne0VzvlyVwk= Xref: news1.google.com comp.lang.ada:19285 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Date: 2011-12-01T10:51:58+00:00 List-Id: Adam Beneschan writes: > On Nov 30, 12:35 am, Simon Wright wrote: >> "Rego, P." writes: >> >> You ought to wait until the task has terminated before freeing it. >> >> > How could I wait for the task termination? >> > Could be something like >> >> >    procedure Destruct (T : access Test_Class) is >> >       T_Ptr : Test_Class_Ptr := Test_Class_Ptr (T); >> >    begin >> >       T.Primary.Finish; >> >       DelayUntilTaskTermination (T_Ptr.Primary); >> >       Free (T_Ptr); >> >    end Destruct; >> >> > ? But is there some package with something like it? >> >>    while not T_Ptr.Primary'Terminated loop >>       delay 0.001; >>    end loop; > > Is it just me, or are there others who think that resorting to code > like this is ... well, icky? This was an answer to the specific question. In the context where I used this scheme, it would have been completely inappropriate to have an unbounded loop like this in the main context; so the actual delay and Unchecked_Deallocation was handed over to a low-priority housekeeping task. To do this required cooperation from the code generator; altogether too complex to go into here! (and I'm by no means sure that the design is the best possible). I think I'd be concerned if an implementation arranged to do this sort of thing 'under the hood'. How would it know what would be an appropriate 'lower priority', for example? I'm not sure that the code above is actually icky. You might think that the aspects of the language that force you to do this are icky; but I think it's quite reasonable. I'd be even happier if a program that tried to deallocate an unterminated task was *required* to receive Tasking_Error or Program_Error; that way we'd have to do something about it.