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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Finalization of library level tasks Date: Sun, 15 Apr 2018 16:12:57 +0200 Organization: Aioe.org NNTP Server Message-ID: References: NNTP-Posting-Host: kQkuQcRDy1QFvWpyB1foYw.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 X-Notice: Filtered by postfilter v. 0.8.3 Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:51517 Date: 2018-04-15T16:12:57+02:00 List-Id: On 2018-04-15 16:02, Jeffrey R. Carter wrote: > On 04/15/2018 03:40 PM, Dmitry A. Kazakov wrote: >> >> When an instance of T is declared in a library level package, then >> Finalize is never called, I guess because the task must terminate >> first due to some rules about its masters. > > The rule is that finalization occurs after all dependent tasks have > terminated, presumably so a task cannot access a finalized object. There is only environment task. >> Is there a way to work this around? > > That depends on the problem, but usually a design can be reworked to > provide for termination of tasks. The problem is that Finalize is called when the object is declared in a nested scope: procedure Main is Data : X; begin Data.Worker := new Worker_Type; end Main; -- Finalize is called (and terminates the task) This does not work: package Library_Level is Data : X; end Library_Level; with Library_Level; procedure Main is begin Library_Level.Data.Worker := new Worker_Type; end Main; -- Finalize is not called (presumably waiting for the task) -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de