comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Class with task destructor
Date: Wed, 23 Nov 2011 18:15:24 -0600
Date: 2011-11-23T18:15:24-06:00	[thread overview]
Message-ID: <jak2av$j9q$1@munin.nbi.dk> (raw)
In-Reply-To: bf5f741b-8ced-4530-8090-df6d4e730a5e@e2g2000vbb.googlegroups.com

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2581 bytes --]

"Adam Beneschan" <adam@irvine.com> wrote in message 
news:bf5f741b-8ced-4530-8090-df6d4e730a5e@e2g2000vbb.googlegroups.com...
>On Nov 22, 9:04 pm, Yannick Duch�ne (Hibou57)
<yannick_duch...@yahoo.fr> wrote:
>> Le Wed, 23 Nov 2011 03:44:39 +0100, Adam Beneschan <a...@irvine.com> a
>> �crit:> The language rules say that Unchecked_Deallocation doesn't force 
>> tasks
>> > to terminate.
>>
>> But it should, because unless I missed something, it seems in this 
>> example
>> case at least, this lead to a dangling reference.
>
>*Any* use of Unchecked_Deallocation can lead to a dangling reference,
>which is why it's called Unchecked.  But also note that the language
>explicitly says that if you use Unchecked_Deallocation on an object
>that contains tasks, the object might not actually disappear
>(13.11.2(9)).  I'm not sure if there are language rules that say that
>the object *must* not be deallocated immediately in a case like this,
>where the task has a discriminant that refers to the object being
>freed.  I don't have time to look into it at the moment.  Maybe
>someone else knows?

The task continues to run (always) through a UC. The compiler has to ensure 
that works, and if that means not deallocating the object, that would work. 
Janus/Ada doesn't work this way, all of the task information is in the TCB 
and there is no connection to the enclosing object. So we can deallocate it 
immediately - the task will still continue to work. TCBs are reused when the 
tasks terminate, and never before.

The requirement that tasks continue to run means that putting a task 
directly in an object will typically lead to a language-required storage 
leak. I always suggest avoiding that. (All of my programs that use tasks use 
fixed pools of tasks that reset themselves after use, in large part because 
tasks can't be managed like other objects.)

One could argue that this behavior is a bug in the Ada Standard (I've 
certainly said that in the past), but there are a number of technical 
reasons that doing something else would be problematical. And changing it 
now would definitely be incompatible - any program that depends on the task 
continuing to run would fail (and in the worst possible way - without any 
indication of the change). We tried to do something else for subpools, but 
the implementation costs were out of hand, and essentially we decided to 
punt (the behavior of tasks in subpools is unspecified) -- hoping to fix 
this somewhere down the line.

                                              Randy.


                           -- Adam





  reply	other threads:[~2011-11-24  0:15 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 [this message]
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
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