comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: On absurdity of collections 7.6.1 (11.1/3)
Date: Thu, 30 Sep 2021 20:40:33 -0500	[thread overview]
Message-ID: <sj5oui$qt7$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: sj5127$1bbu$1@gioia.aioe.org

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message 
news:sj5127$1bbu$1@gioia.aioe.org...
> On 2021-09-30 20:23, G.B. wrote:
>> On 29.09.21 11:09, Dmitry A. Kazakov wrote:
>>> For Ada programmers who wonder what it is,
>> What's the reasoning behind run-time selection of storage pools?
>
> It happens quite frequently. Here is an example without controlled 
> objects, just an illustration of a dynamically selected storage pool.
>
> Consider a JSON parser. It is be an Ada object with a buffer inside which 
> size is a discriminant. On top of the buffer sits an arena pool. The parts 
> of the parsed JSON object are allocated in the arena. After parsing the 
> result can be used until the next parsing that will sweep the arena, no 
> Unchecked_Deallocate.
>
> In this case the collection rule will have no effect since JSON objects do 
> not require controlled components (or tasks, yet another thing killed by 
> the collection).

To implement an arena pool, you need to use the subpool mechanism (which 
does properly handle finalization when you "sweep the pool" as you put it). 
Each "arena" is a separate subpool, and you can dump the entire subpool with 
Unchecked_Deallocate_Subpool.

It helps to use the tool designed for the job. ;-)

                                Randy.


  reply	other threads:[~2021-10-01  1:40 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-29  9:09 On absurdity of collections 7.6.1 (11.1/3) Dmitry A. Kazakov
2021-09-29 11:05 ` Simon Wright
2021-09-29 11:20   ` Dmitry A. Kazakov
2021-09-29 21:38     ` Simon Wright
2021-09-30  8:07       ` Dmitry A. Kazakov
2021-09-30  8:35         ` Simon Wright
2021-09-30  8:49           ` Dmitry A. Kazakov
2021-10-01  1:37         ` Randy Brukardt
2021-10-01  7:57           ` Dmitry A. Kazakov
2021-09-30  0:23     ` Randy Brukardt
2021-09-30  8:06       ` Dmitry A. Kazakov
2021-09-30 18:23 ` G.B.
2021-09-30 18:52   ` Dmitry A. Kazakov
2021-10-01  1:40     ` Randy Brukardt [this message]
2021-10-01  7:57       ` Dmitry A. Kazakov
replies disabled

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