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,ASCII-7-bit Received: by 10.68.35.131 with SMTP id h3mr3771125pbj.1.1322044015283; Wed, 23 Nov 2011 02:26:55 -0800 (PST) Path: lh20ni8646pbb.0!nntp.google.com!news1.google.com!news.glorb.com!feeder.erje.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Brian Drummond Newsgroups: comp.lang.ada Subject: Re: Class with task destructor Date: Wed, 23 Nov 2011 10:26:54 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: <30604696.94.1322013045135.JavaMail.geo-discussion-forums@yqzz20> Mime-Version: 1.0 Injection-Date: Wed, 23 Nov 2011 10:26:54 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="DkTdSjxOCm6DqG+Uf7eArg"; logging-data="29654"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18BINInMKBXelcEkyfmcUGzrRUiHamob84=" User-Agent: Pan/0.134 (Wait for Me; GIT cb32159 master) Cancel-Lock: sha1:pGTKuTl62z8jfFZewHBdVcaKLh8= Xref: news1.google.com comp.lang.ada:19072 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Date: 2011-11-23T10:26:54+00:00 List-Id: On Tue, 22 Nov 2011 17:50:45 -0800, Rego, P. wrote: > So now I have a class with a task inside and a Constructor, and I want > to implement a destructor. > So I thought that if I unallocate the object, the task inside would be > dead too, because the object would be its master. It looks that I'm > wrong, because the execution led me to > > ^ 1^ 1^ 1^ 1^ 1^ 1^ 1^ 1^ 1^ 1^ 6295912^ 6295912^ (...) Are you by any chance trying something like the RAII pattern in C++? (which as far as I can see, stands for "automatic destruction is orderly shutdown") If so, I think I'm with Dmitry, in that Controlled (or Limited_Controlled) give you the tools to automate the process. So your approach (2) is correct; you must stop the task before deallocating it. However your class user doesn't need to know that, because you can put the detail in Finalize. (which, if Simon is right, may need to become a little more complex) - Brian