comp.lang.ada
 help / color / mirror / Atom feed
* Question: What's the difference between pools of pools and Ada 2012's new subpools?
@ 2013-02-14  0:12 Shark8
  2013-02-14  0:56 ` Randy Brukardt
  0 siblings, 1 reply; 7+ messages in thread
From: Shark8 @ 2013-02-14  0:12 UTC (permalink / raw)


I recently asked this question on Stackoverflow ( http://stackoverflow.com/questions/14840702/what-are-the-differerences-between-the-new-ada-sub-pool-features-and-pools-of-po ).

I haven't used pools at all, yet; so it's quite likely I'm missing something.

-------
-- Pool of Pools
----------------------------------
-- Minnesota: Land of 10,000 Lakes
type Minnesota(Size: Storage_Count) is new Root_Storage_Pool with private;
type Lake(Size: Storage_Count) is new Root_Storage_Pool with private
     with Storage_Pool => Minnasota;
-- ...
type Pooled is [...] with Storage_Pool => Lake;

-------
-- Sub-Pools
----------------------------------
  type Pond(Size: Storage_Count) is new Root_Storage_Pool_With_Subpools with private;
  subtype My_Handle is Subpool_Handle;

[Note: examples uncompiled, just for illustrative purpose]



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Question: What's the difference between pools of pools and Ada 2012's new subpools?
  2013-02-14  0:12 Question: What's the difference between pools of pools and Ada 2012's new subpools? Shark8
@ 2013-02-14  0:56 ` Randy Brukardt
  2013-02-14  2:34   ` Shark8
  2013-02-17  1:06   ` Shark8
  0 siblings, 2 replies; 7+ messages in thread
From: Randy Brukardt @ 2013-02-14  0:56 UTC (permalink / raw)


"Shark8" <onewingedshark@gmail.com> wrote in message 
news:8fe47d10-1889-43e7-be85-510ece95c1a6@googlegroups.com...
>I recently asked this question on Stackoverflow ( 
>http://stackoverflow.com/questions/14840702/what-are-the-differerences-between-the-new-ada-sub-pool-features-and-pools-of-po ) 
>.
>
> I haven't used pools at all, yet; so it's quite likely I'm missing 
> something.
>
> -------
> -- Pool of Pools
> ----------------------------------
> -- Minnesota: Land of 10,000 Lakes
> type Minnesota(Size: Storage_Count) is new Root_Storage_Pool with private;
> type Lake(Size: Storage_Count) is new Root_Storage_Pool with private
>     with Storage_Pool => Minnasota;

Aspect Storage_Pool only applies to access types (13.11(15) and others), and 
type Lake is not an access type, so this is illegal (and makes no sense as 
well).

You could implement one pool by putting other pools within its 
implementation (say Minnesota here including a an array of 10000 Lakes :-). 
But you'd then have to have a way to select which item belongs to each, 
ahem, subpool. And you'd be reinventing the wheel.

There is also the issue of finalization. The subpool mechanism ensures that 
objects don't outlive their subpool (pointers to the objects might outlive 
the subpool, but not the object themselves), even when the subpool is 
explicitly destroyed early (just as Unchecked_Deallocation does). There's no 
good way to do that without language support (every hand-written subpool 
implementation that we talked about insisted that no controlled, protected, 
or task objects be allocated from it, which is obviously limiting).

Let me assure you, getting this right was hard and contentious. It was 
nearly dropped a couple of times. Doing it yourself wouldn't be contentious 
(I hope!), but it would still be hard. Since the ARG has already done the 
dirty work, it's best to use it.

                                                Randy.


                                                 Randy.


                                  Randy.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Question: What's the difference between pools of pools and Ada 2012's new subpools?
  2013-02-14  0:56 ` Randy Brukardt
@ 2013-02-14  2:34   ` Shark8
  2013-02-17  1:06   ` Shark8
  1 sibling, 0 replies; 7+ messages in thread
From: Shark8 @ 2013-02-14  2:34 UTC (permalink / raw)


Thank you for that explanation, it's quite informative.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Question: What's the difference between pools of pools and Ada 2012's new subpools?
  2013-02-14  0:56 ` Randy Brukardt
  2013-02-14  2:34   ` Shark8
@ 2013-02-17  1:06   ` Shark8
  2013-02-17  9:06     ` Dmitry A. Kazakov
  1 sibling, 1 reply; 7+ messages in thread
From: Shark8 @ 2013-02-17  1:06 UTC (permalink / raw)


Secondary questions:

Are there any good tutorials-on/examples-of using pools?
Subpools?



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Question: What's the difference between pools of pools and Ada 2012's new subpools?
  2013-02-17  1:06   ` Shark8
@ 2013-02-17  9:06     ` Dmitry A. Kazakov
  2013-02-17 11:47       ` Simon Wright
  0 siblings, 1 reply; 7+ messages in thread
From: Dmitry A. Kazakov @ 2013-02-17  9:06 UTC (permalink / raw)


On Sat, 16 Feb 2013 17:06:02 -0800 (PST), Shark8 wrote:

> Are there any good tutorials-on/examples-of using pools?

Stack pools ("arenas"):

http://www.dmitry-kazakov.de/ada/components.htm#Pools_etc

Using pools for injecting data into objects ("multiple inheritance"), e.g.
list headers, graph node headers:

http://www.dmitry-kazakov.de/ada/components.htm#Generic_Doubly_Linked_Web
http://www.dmitry-kazakov.de/ada/components.htm#Generic_Directed_Graph

> Subpools?

Not yet. Subpools could be useful for concurrent and heavy duty
applications.

As Randy said the problem with pools when used for management the life
cycle of objects is finalization of controlled objects. If subpools
alleviate this problem is to be seen.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Question: What's the difference between pools of pools and Ada 2012's new subpools?
  2013-02-17  9:06     ` Dmitry A. Kazakov
@ 2013-02-17 11:47       ` Simon Wright
  2013-02-18 23:24         ` Randy Brukardt
  0 siblings, 1 reply; 7+ messages in thread
From: Simon Wright @ 2013-02-17 11:47 UTC (permalink / raw)


"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:

> As Randy said the problem with pools when used for management the life
> cycle of objects is finalization of controlled objects. If subpools
> alleviate this problem is to be seen.

What Randy said was that the _hand-written_ subpool implementations the
ARG had seen had problems with finalizable objects. Of coaurse, in the
end all implementations are hand-written by somebody.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Question: What's the difference between pools of pools and Ada 2012's new subpools?
  2013-02-17 11:47       ` Simon Wright
@ 2013-02-18 23:24         ` Randy Brukardt
  0 siblings, 0 replies; 7+ messages in thread
From: Randy Brukardt @ 2013-02-18 23:24 UTC (permalink / raw)


"Simon Wright" <simon@pushface.org> wrote in message 
news:lyd2vzqi0w.fsf@pushface.org...
> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
>
>> As Randy said the problem with pools when used for management the life
>> cycle of objects is finalization of controlled objects. If subpools
>> alleviate this problem is to be seen.
>
> What Randy said was that the _hand-written_ subpool implementations the
> ARG had seen had problems with finalizable objects. Of coaurse, in the
> end all implementations are hand-written by somebody.

Right (I think). When you create your own subpool-like mechanism, you can't 
force finalization of objects (unless you keep a list of objects in the 
subpool and free them individually, which would defeat the purpose). So most 
people's simply say that they cannot be used with controlled objects (or 
tasks or protected objects). Which is limiting.

The subpool mechanism in Ada 2012 is designed to ensure that objects are 
finalized no later than when the subpool is discarded (via 
Unchecked_Deallocate_Subpool). In that sense, it works just like 
Unchecked_Deallocation (except all at once, rather than one at a time). Of 
course, I can't know whether GNAT actually implements this correctly!

                                   Randy.





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-02-18 23:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-14  0:12 Question: What's the difference between pools of pools and Ada 2012's new subpools? Shark8
2013-02-14  0:56 ` Randy Brukardt
2013-02-14  2:34   ` Shark8
2013-02-17  1:06   ` Shark8
2013-02-17  9:06     ` Dmitry A. Kazakov
2013-02-17 11:47       ` Simon Wright
2013-02-18 23:24         ` Randy Brukardt

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