comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: asynchronous task communication
Date: Thu, 3 Jan 2013 16:27:49 -0600
Date: 2013-01-03T16:27:49-06:00	[thread overview]
Message-ID: <kc50ld$1u0$1@munin.nbi.dk> (raw)
In-Reply-To: MY2dnX5O5NO_TXnNnZ2dnUVZ_hudnZ2d@earthlink.com

"Charles Hixson" <charleshixsn@earthlink.net> wrote in message 
news:MY2dnX5O5NO_TXnNnZ2dnUVZ_hudnZ2d@earthlink.com...
...
> Yes, it's doable, but I'd *really* rather avoid that.  And I'm sure there 
> must be some reasonable way to deallocate a Vector.  That I don't know 
> what it is doesn't convince me that it doesn't exist.  Perhaps Clear or 
> Delete would do it, but I haven't found this documented.  I'm guessing 
> that if I store access variables in a Vector, and then deallocate the item 
> the access variable holds (updating the access variable to null), that 
> will free most of the space, but deallocating the Vector itself is not so 
> clear.  I can't tell whether there are any handles to it that I don't know 
> about.  Perhaps it's somewhere in the AARM.

I don't understand this comment (and probably no one else has, either, as no 
one has commented on it).

The entire reason the Ada.Containers library of packages (including Vectors) 
exists is to eliminate the need to manage storage. (If you don't mind 
managing the storage, the operations are trivial to write yourself, and 
probably more efficient as well.) As such, there is quite purposely no 
visibility into the storage management of any of the Ada.Containers. All 
that's required is that the memory is freed when the object is destroyed or 
overwritten (see A.18.2(253)).

Of course, if you're putting an access to some object into a container, you 
still have to manage the storage for the object. It's better (but not always 
possible) to put the objects themselves directly into the containers. When 
that's not possible, sometimes its possible to put cursors (for another 
container) into a container. In both cases, the containers will manage the 
storage so you don't have to.

Personally, I wouldn't bother with using a Vector container for access 
values. You're still going to have to do most of the storage management 
yourself; you might as well do all of it yourself. An access to 
unconstrained array of access values is easy to manage and you won't have 
any questions about when memory is freed. The most painful case happens when 
you need to grow the structure, but just copying it into a larger value is 
not likely to be very expensive because of the small size of the 
elements.(After all, this is pretty much what is happening inside of an 
instance of Vectors.)

The big value of the containers is when managing large elements directly, 
especially indefinite elements like class-wide objects (something Ada 
doesn't allow you to do directly). Just because you *can* store access 
values into a container doesn't mean you should. But of course YMMV.

                                          Randy.





  parent reply	other threads:[~2013-01-03 22:27 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-31  0:16 asynchronous task communication Charles Hixson
2012-12-31  9:04 ` Simon Wright
2012-12-31 11:49   ` Simon Wright
2012-12-31 10:50 ` J-P. Rosen
2012-12-31 12:09 ` Georg Bauhaus
2012-12-31 18:52   ` Charles Hixson
2012-12-31 20:18     ` Shark8
2012-12-31 21:09     ` Niklas Holsti
2012-12-31 22:15       ` Randy Brukardt
2013-01-01  3:58         ` Charles Hixson
2013-01-01  4:48           ` tmoran
2013-01-01 17:59             ` Charles Hixson
2013-01-01  3:51       ` Charles Hixson
2013-01-01  9:59         ` Dmitry A. Kazakov
2013-01-01 10:38         ` Brian Drummond
2013-01-01 12:32         ` Jeffrey Carter
2013-01-01 18:21           ` Charles Hixson
2013-01-01 18:54             ` Robert A Duff
2013-01-02  7:36               ` Charles Hixson
2013-01-02  9:55                 ` Dmitry A. Kazakov
2013-01-02 19:02                   ` Charles Hixson
2013-01-02 20:35                     ` Dmitry A. Kazakov
2013-01-03  0:20                       ` Charles Hixson
2013-01-03  6:34                         ` Charles Hixson
2013-01-03  8:50                         ` Dmitry A. Kazakov
2013-01-03 19:01                           ` Charles Hixson
2013-01-03 10:01                         ` J-P. Rosen
2013-01-03 19:29                           ` Charles Hixson
2013-01-04  8:17                             ` J-P. Rosen
2013-01-05  4:31                               ` Charles Hixson
2013-01-09  8:34                                 ` Stephen Leake
2013-01-03 22:27                         ` Randy Brukardt [this message]
2013-01-05  5:18                           ` Charles Hixson
2013-01-05  8:48                             ` Niklas Holsti
2013-01-06 22:55                               ` Charles Hixson
2013-01-07  0:38                                 ` tmoran
2013-01-07  6:07                                 ` Shark8
2013-01-07 10:49                                 ` Brian Drummond
2013-01-07 18:27                                   ` Jeffrey Carter
2013-01-08 12:02                                     ` Brian Drummond
2013-01-08 17:12                                       ` Jeffrey Carter
2013-01-08 18:18                                         ` Simon Wright
2013-01-08 20:29                                           ` Dmitry A. Kazakov
2013-01-08 21:01                                           ` Jeffrey Carter
2013-01-08 21:14                                             ` Simon Wright
2013-01-08 22:11                                               ` Randy Brukardt
2013-01-08 22:52                                               ` Jeffrey Carter
2013-01-08 22:26                                         ` Brian Drummond
2013-01-08  2:41                             ` Randy Brukardt
2013-01-02 22:43         ` Niklas Holsti
2013-01-03  1:30           ` Charles Hixson
2013-01-03 12:11             ` Georg Bauhaus
2013-01-03 13:17               ` Dmitry A. Kazakov
2013-01-05 20:19               ` Charles Hixson
2013-01-07  4:01                 ` Shark8
2013-01-01 19:59     ` J-P. Rosen
replies disabled

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