comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adambeneschan@aol.com>
Subject: Re: Questions on Storage Pools
Date: Mon, 12 Aug 2013 10:14:23 -0700 (PDT)
Date: 2013-08-12T10:14:23-07:00	[thread overview]
Message-ID: <c7573456-e37d-43f4-ab44-e1b37ade914d@googlegroups.com> (raw)
In-Reply-To: <90b5c304-417e-4303-931c-e86d34e17541@googlegroups.com>

I think you're confusing "finalization" with "storage reclamation".  They're not the same thing.  Finalization mostly means calling Finalize routines on an object and its subcomponents, where they exist; there are extra actions for protected types.  Finalization doesn't even have to involve any freeing of storage.  If a Finalize routine does free storage, it would normally do so with Unchecked_Deallocation.  But it wouldn't deallocate the object being finalized, since Finalize's parameter is the object itself as an IN OUT parameter, not an access to the object.  

An access type can have a Storage_Size clause, or it can have a Storage_Pool clause.  It cannot have both (13.11(3)).  If it has a Storage_Size clause, the intent is that some block of memory (whose size is Storage_Size plus possibly a little extra) is set aside, and all "new" operations that return the access type use memory in that block for the new object.  If the object contains accesses to other objects (of a different access type), those accessed objects wouldn't be in the same block.  It would make sense for a Finalize procedure to deallocate those accessed objects, but that wouldn't affect what happens in the block of size Storage_Size.

If there's still something that isn't clear, I'll try to answer.

                                -- Adam
  

On Saturday, August 10, 2013 2:45:20 PM UTC-7, AdaMagica wrote:
> This is a question to language lawyers.
> 
> First two citations:
> 
> RM 13.11(18) If Storage_Size is specified for an access type, then the Storage_Size of this pool is at least that requested, and the storage for the pool is reclaimed when the master containing the declaration of the access type is left.
> 
> 
> 
> RM 7.6.1(11.1/3) Each nonderived access type T has an associated *collection*, which is the set of objects created by allocators of T ... Finalization of a collection consists of finalization of each object in the collection, in an arbitrary order. The collection of an access type is an object implicitly declared at the following place:
> 
> (11.2/3) For a named access type, the first freezing point (see 13.14) of the type.
> 
> 
> 
> So, IIUC 7.6.1, if the master of an access type is left, all still existing objects in the collection are finalized. (Note that these paragraphs and the definition of *collection* are new in Ada 2012.)
> 
> However 13.11 seems to say that this is the case only for access types with Storage_Size defined.
> 
> Further: If several access types use the same (user defined) storage pool, and the master of one of them is left (i.e. this access type has a deeper access level than the others and also deeper than the storage pool itself), is then the associated collection (i.e. a part of all objects allocated in the storage pool) finalized?
> 
> In other words: Is the collection of an access type with a defined storage pool part of this pool and finalized separately?
> 
> I would be very thankful for clarification.
> 
> C. Grein



  reply	other threads:[~2013-08-12 17:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-10 21:45 Questions on Storage Pools AdaMagica
2013-08-12 17:14 ` Adam Beneschan [this message]
2013-08-13 19:36   ` AdaMagica
2013-08-13 20:21     ` Adam Beneschan
2013-08-13 21:02       ` Randy Brukardt
2013-08-14  7:40         ` AdaMagica
replies disabled

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