comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Problem with task component
Date: Mon, 24 Sep 2012 09:43:58 -0700 (PDT)
Date: 2012-09-24T09:43:58-07:00	[thread overview]
Message-ID: <ddb97b21-d751-422c-8f7f-497c39f2c4ab@googlegroups.com> (raw)
In-Reply-To: <697f51fe-6971-477a-bf50-cb1b12c792d9@googlegroups.com>

On Monday, September 24, 2012 9:13:12 AM UTC-7, AdaMagica wrote:
> On Monday, September 24, 2012 5:44:32 PM UTC+2, Adam Beneschan wrote:
> 
> > I've been trying to think of a way to get around the "forget" problem by using controlled types.  My first thought was to define a controlled record (i.e. derived from Ada.Finalization.Limited_Controlled) that has a task as a component, and have the Finalize routine for the controlled type call the Shutdown entry.  That way, since the shutdown protocol would be defined, in essence, right by the definition of the task type, there's no way a procedure that uses the type could "forget" to call Shutdown.  No good, though; 7.6.1(4) says that the Finalize routine on the record object would be called *after* the task terminates.  So it would be too late.
> 
> 
> 
> Why not use abort in this case? (In the general case, abort might not work immediately or be dangerous, but under these circumstances? I used it e.g. effectively when a commercial flight simulator program - all tasks inside have infinite loops - had to be stopped.)

It wouldn't solve the problem.  Using a Shutdown entry, and requiring that the master call it before it leaves, seems to be the best solution, but the issue is that it requires the master to call the entry, and a coder could forget that (or they could put the Shutdown call at the end of the block but then sabotage themselves by putting a RETURN statement in the middle of the code sequence).  Using an abort statement is no better. 

                          -- Adam




  reply	other threads:[~2012-09-24 16:43 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-19 18:22 Problem with task component Simon Wright
2012-09-19 18:48 ` Dmitry A. Kazakov
2012-09-19 20:40   ` Simon Wright
2012-09-19 21:11     ` Dmitry A. Kazakov
2012-09-19 21:48       ` Simon Wright
2012-09-24  5:28         ` J-P. Rosen
2012-09-24  8:23           ` Simon Wright
2012-09-24 13:37             ` J-P. Rosen
2012-09-24 14:17               ` Simon Wright
2012-09-24 17:53               ` Robert A Duff
2012-09-24 20:40                 ` J-P. Rosen
2012-09-24 15:44             ` Adam Beneschan
2012-09-24 16:13               ` AdaMagica
2012-09-24 16:43                 ` Adam Beneschan [this message]
2012-09-24 16:29               ` Dmitry A. Kazakov
2012-09-24 20:49                 ` J-P. Rosen
2012-09-25  7:35                   ` Dmitry A. Kazakov
2012-09-25 17:52                     ` J-P. Rosen
2012-09-25 18:35                       ` Dmitry A. Kazakov
2012-09-25 19:22                         ` J-P. Rosen
2012-09-26  7:27                           ` Dmitry A. Kazakov
2012-09-26 11:49                             ` Georg Bauhaus
2012-09-26 14:13                               ` Dmitry A. Kazakov
2012-09-19 19:44 ` Adam Beneschan
replies disabled

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