From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-0.9 required=3.0 tests=BAYES_00,XPRIO autolearn=no autolearn_force=no version=3.4.6 Path: eternal-september.org!reader02.eternal-september.org!gandalf.srv.welterde.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: On absurdity of collections 7.6.1 (11.1/3) Date: Thu, 30 Sep 2021 20:40:33 -0500 Organization: JSA Research & Innovation Message-ID: References: Injection-Date: Fri, 1 Oct 2021 01:40:34 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="27559"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader02.eternal-september.org comp.lang.ada:62910 List-Id: "Dmitry A. Kazakov" 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.