comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Termination of periodic tasks
Date: Mon, 16 Jun 2014 17:08:42 +0200
Date: 2014-06-16T17:08:42+02:00	[thread overview]
Message-ID: <13go3b52zfojz$.s0ft11yb9bmx$.dlg@40tude.net> (raw)
In-Reply-To: slrnlptu84.i0l.lithiumcat@nat.rebma.instinctive.eu

On Mon, 16 Jun 2014 14:02:47 +0000 (UTC), Natasha Kerensikova wrote:

> On 2014-06-15, Jeffrey Carter <spam.jrcarter.not@spam.not.acm.org> 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.

It will be called. The master here is not the instance of Watcher. Watcher
would happen to be the master only if Signal_Target were its component of
the Typed_Task. Since you are using rather an access to Typed_Task,
everything is OK.

When using the solution with an entry the difference to signalling an event
is that you have to catch Tasking_Error if the task ended prematurely.
Another difference is that when you have a pool of tasks, they may share
the same exiting event.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


  reply	other threads:[~2014-06-16 15:08 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-15 10:10 Termination of periodic tasks Natasha Kerensikova
2014-06-15 12:11 ` Dmitry A. Kazakov
2014-06-15 15:23 ` J-P. Rosen
2014-06-16 13:54   ` Natasha Kerensikova
2014-06-17 20:14     ` Charles H. Sampson
2014-06-18  7:32       ` Dmitry A. Kazakov
2014-06-15 16:54 ` Jeffrey Carter
2014-06-16 14:02   ` Natasha Kerensikova
2014-06-16 15:08     ` Dmitry A. Kazakov [this message]
2014-06-16 17:08     ` Jeffrey Carter
2014-06-17  6:57       ` Natasha Kerensikova
2014-06-17  7:37         ` Dmitry A. Kazakov
2014-06-17  7:47           ` Natasha Kerensikova
2014-06-17  8:45             ` Dmitry A. Kazakov
2014-06-17  9:00               ` Natasha Kerensikova
2014-06-17 12:55                 ` Dmitry A. Kazakov
2014-06-17 14:51                   ` J-P. Rosen
2014-06-17 16:44                     ` Dmitry A. Kazakov
2014-06-17 20:00                       ` Randy Brukardt
2014-06-17 20:16                         ` Jeffrey Carter
2014-06-17 21:30                         ` Simon Wright
2014-06-17 12:02         ` Jacob Sparre Andersen
2014-06-17 19:32           ` Natasha Kerensikova
2014-06-17 17:53         ` Jeffrey Carter
2014-06-17 20:03           ` Randy Brukardt
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox