On 14/08/2023 4:10 AM, ryuukk_ wrote:
Also if you want people to use D for games, you want an allocator API that doesn't use RAII, same for exceptions btw

After thinking about it a bit, this would suggest to me that you are trying to solve a problem that I would outright recommend against using an abstraction to solve.

Memory allocators that only deal with fixed sized memory blocks, that are specific to a thread are going to have the best performance. If this is the case you don't need an abstraction at all.

A rough pseudo code where no RCAllocator would be used:

```d
module particles;

private __gshared FreeList!(AllocatorList!(Region!(SystemMapper, __traits(classInstanceSize, Particle)))) allocator;

final class Particle {
        int lifeLeft;

        void free() {
                allocator.dispose(this);
        }

        static Particle create() {
                return allocator.make!Particle();
        }
}
```

Of course you'd only call free/create as part of a particle manager, but this should still demonstrate that an abstraction isn't required if you understand your data and memory lifetimes well enough to see any performance improvement by using a memory allocator library.
  • std.experimental... IchorDev via Digitalmars-d-learn
    • Re: std.exp... ryuukk_ via Digitalmars-d-learn
      • Re: std... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
        • Re:... ryuukk_ via Digitalmars-d-learn
          • ... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
            • ... ryuukk_ via Digitalmars-d-learn
              • ... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
              • ... Guillaume Piolat via Digitalmars-d-learn
            • ... IchorDev via Digitalmars-d-learn
    • Re: std.exp... Paul Backus via Digitalmars-d-learn

Reply via email to