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=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader02.eternal-september.org!aioe.org!x6YkKUCkj2qHLwbKnVEeag.user.46.165.242.91.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: On absurdity of collections 7.6.1 (11.1/3) Date: Fri, 1 Oct 2021 09:57:46 +0200 Organization: Aioe.org NNTP Server Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: gioia.aioe.org; logging-data="30393"; posting-host="x6YkKUCkj2qHLwbKnVEeag.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org"; User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 X-Notice: Filtered by postfilter v. 0.9.2 Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:62912 List-Id: On 2021-10-01 03:40, Randy Brukardt wrote: > "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. Not in this case, where all pool is arena. Allocate takes memory from the object's buffer. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de