On Sunday, 1 November 2015 at 09:48:20 UTC, ref2401 wrote:
On Friday, 30 October 2015 at 05:21:17 UTC, Rikki Cattermole wrote:
What I normally do for memory to be owned by the thread is:

auto foo(IAllocator alloc=theAllocator()) {...}

Where as for if it is global to the process:

auto foo(IAllocator alloc=processAllocator()) {...}

Basically it is the difference between a screenshot of a display and a window instance.

What do other think?

Create a "repository" of allocators. The "programmers" query the allocators for their "best fit", but because it is a repository, they are easier to deal with than hard coding.

E.g.,

auto allocator = GetAllocator(allocatorsRepository.processAllocator);

GetAllocator would get the actual allocator using the arg as a "hint".

One could, hypothetically, make this as complex as one would want. e.g., passing the file name as an argument(hidden) which can then be used as a constraint on the allocator allocation(pun ;). e.g., you can have file specific optimization techniques by altering the allocation strategy per file(or better yet, per line).

Since all that can be done retroactively, it alleviates some of the problems with the programmers interfacing directly with std.experimental.allocator. They have to go through your interface first which gives you some control.

You could then print special debug messages sort of like -vgc but instead, for allocation strategies. The sky's the limit! Have fun with it!




Reply via email to