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!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Natasha Kerensikova Newsgroups: comp.lang.ada Subject: Re: Termination of periodic tasks Date: Mon, 16 Jun 2014 14:02:47 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: Injection-Date: Mon, 16 Jun 2014 14:02:47 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="76a49b86bc3e16725b7cfca3d85cb4c8"; logging-data="23526"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+RkuyEUda5JJT9MHkky1Uu" User-Agent: slrn/1.0.1 (FreeBSD) Cancel-Lock: sha1:tjAJZH6PemzCRfLM/TzPcLr4E+M= Xref: news.eternal-september.org comp.lang.ada:20363 Date: 2014-06-16T14:02:47+00:00 List-Id: Hello, On 2014-06-15, Jeffrey Carter wrote: > On 06/15/2014 03:10 AM, Natasha Kerensikova wrote: >> >> A timed select to wait for an entry that exists the loop would be fine >> too, but how can I detect program termination to call the entry? >> Could something be worked with a user-defined Finalize? > > ARM 7.6.1 says, "For the finalization of a master, dependent tasks are first > awaited, as explained in 9.3. Then each object ... is finalized if the object > was successfully initialized and still exists." > > So the task has to terminate before Finalize is called. That seems at odds with the solution proposed by Dmitry, isn't it? Considering the following skeleton spec, package To_Be_Discussed is task type Typed_Task is entry Terminate; end Typed_Task; type Task_Access is access Typed_Task; task Singleton_Task is entry Terminate; end Singleton_Task; type Watcher is new Ada.Finalization.Limited_Controlled with record Signal_Target : Task_Access; end record; overriding procedure Finalize (Object : in out Watcher); end To_Be_Discussed; As far as I can tell, Singleton_Task and task(s) created using an allocator for Task_Access have the same master. I understood Dimtry's solution as calling Terminate entry from Watcher.Finalize. However what you quote seems to indicate that Watcher.Finalize won't be called until Singleton_Task and any allocated task in a Task_Access are termninated by themselves. So I'm still lost on how to solve my problem, though I still have to experiment with ideas like the specification above. Thanks for your help, Natasha