comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Class with task destructor
Date: Thu, 01 Dec 2011 10:51:58 +0000
Date: 2011-12-01T10:51:58+00:00	[thread overview]
Message-ID: <m2aa7c7eep.fsf@pushface.org> (raw)
In-Reply-To: a6426266-d8ca-461d-ab5e-2bf67cbc56a1@s4g2000yqk.googlegroups.com

Adam Beneschan <adam@irvine.com> writes:

> On Nov 30, 12:35 am, Simon Wright <si...@pushface.org> wrote:
>> "Rego, P." <pvr...@gmail.com> writes:
>> >> You ought to wait until the task has terminated before freeing it.
>>
>> > How could I wait for the task termination?
>> > Could be something like
>>
>> >    procedure Destruct (T : access Test_Class) is
>> >       T_Ptr : Test_Class_Ptr := Test_Class_Ptr (T);
>> >    begin
>> >       T.Primary.Finish;
>> >       DelayUntilTaskTermination (T_Ptr.Primary);
>> >       Free (T_Ptr);
>> >    end Destruct;
>>
>> > ? But is there some package with something like it?
>>
>>    while not T_Ptr.Primary'Terminated loop
>>       delay 0.001;
>>    end loop;
>
> Is it just me, or are there others who think that resorting to code
> like this is ... well, icky?

This was an answer to the specific question.

In the context where I used this scheme, it would have been completely
inappropriate to have an unbounded loop like this in the main context;
so the actual delay and Unchecked_Deallocation was handed over to a
low-priority housekeeping task. To do this required cooperation from the
code generator; altogether too complex to go into here! (and I'm by no
means sure that the design is the best possible).

I think I'd be concerned if an implementation arranged to do this sort
of thing 'under the hood'. How would it know what would be an
appropriate 'lower priority', for example?

I'm not sure that the code above is actually icky. You might think that
the aspects of the language that force you to do this are icky; but I
think it's quite reasonable. I'd be even happier if a program that tried
to deallocate an unterminated task was *required* to receive
Tasking_Error or Program_Error; that way we'd have to do something about
it.



  parent reply	other threads:[~2011-12-01 10:51 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-23  1:50 Class with task destructor Rego, P.
2011-11-23  2:44 ` Adam Beneschan
2011-11-23  5:04   ` Yannick Duchêne (Hibou57)
2011-11-23  6:14     ` Adam Beneschan
2011-11-24  0:15       ` Randy Brukardt
2011-11-24  2:48         ` Adam Beneschan
2011-11-29  3:36           ` Randy Brukardt
2011-11-29  9:31             ` Simon Wright
2011-11-29 15:37             ` Adam Beneschan
2011-11-23  8:35 ` Dmitry A. Kazakov
2011-11-23  9:05   ` Simon Wright
2011-11-23 10:41     ` Dmitry A. Kazakov
2011-11-30  1:11     ` Rego, P.
2011-11-30  2:21       ` Adam Beneschan
2011-11-30  8:41         ` Dmitry A. Kazakov
2011-12-01  0:35           ` Randy Brukardt
2011-12-01  6:28             ` J-P. Rosen
2011-12-01 10:55               ` Simon Wright
2011-12-01 21:48               ` Robert A Duff
2011-12-01 22:44                 ` Adam Beneschan
2011-12-02  0:57                 ` Randy Brukardt
2011-12-02  5:57                 ` J-P. Rosen
2011-12-02 15:07                   ` Robert A Duff
2011-12-02 18:41                   ` Jeffrey Carter
2011-12-01  9:25             ` Dmitry A. Kazakov
2011-12-01  1:58         ` Rego, P.
2011-11-30  8:35       ` Simon Wright
2011-11-30 15:36         ` Adam Beneschan
2011-11-30 16:32           ` Robert A Duff
2011-12-01  0:40             ` Randy Brukardt
2011-12-01  8:50               ` Yannick Duchêne (Hibou57)
2011-12-02  0:50                 ` Randy Brukardt
2011-12-02  5:30                   ` Jeffrey Carter
2011-12-02 16:20                     ` Adam Beneschan
2011-12-02 18:01                       ` Dmitry A. Kazakov
2011-12-02 18:50                       ` Jeffrey Carter
2011-12-02 19:03                         ` Adam Beneschan
2011-12-01 10:51           ` Simon Wright [this message]
2011-12-01 22:59             ` Simon Wright
2011-12-01  1:59         ` Rego, P.
2011-11-30  1:47     ` Rego, P.
     [not found]     ` <15090042.1880.1322617401962.JavaMail.geo-discussion-forums@yqkn8>
2011-11-30  8:43       ` Dmitry A. Kazakov
2011-12-01  1:53         ` Rego, P.
2011-12-01  9:28           ` Dmitry A. Kazakov
2011-11-25  2:44   ` Rego, P.
     [not found]   ` <28489797.1088.1322188495508.JavaMail.geo-discussion-forums@yqf20>
2011-11-25  9:19     ` Dmitry A. Kazakov
2011-11-29  3:40       ` Randy Brukardt
2011-11-23 10:26 ` Brian Drummond
2011-11-25  1:37   ` Rego, P.
2011-11-25 13:40     ` Brian Drummond
replies disabled

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