TempAlloc: an unusual request
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Sun Jun 19 17:00:39 PDT 2011
On 06/19/2011 06:20 PM, dsimcha wrote:
> It's ok to allow an object to replace frameInit and frameFree for
> conformance to the general allocator interface, but I'd need to keep
> frameInit and frameFree around. They're useful for functions that return
> pointers to TempAlloc-allocated memory. I don't want to have to pass in
> a RegionAllocator object to each of these because it's too verbose. I
> want to be able to do:
>
> void doStuff() {
> TempAlloc.frameInit();
> scope(exit) TempAlloc.frameFree();
>
> auto arr = getArray();
> }
>
> uint[] getArray() {
> return TempAlloc.newArray!(uint[])(5);
> }
>
>
> My other concern is that giving RegionAllocator reference semantics
> would, IIUC, require an allocation to allocate a RegionAllocator. Since
> TempAlloc is designed to avoid global GC locks/world stopping like the
> plauge, this is obviously bad.
I was actually glad of that particular outcome...
Andrei
More information about the Digitalmars-d
mailing list