On 12/21/11 1:07 AM, foobar wrote:
The containers should allow for (disregard the specifics of the syntax):

Container a = new(SharedMemAllocator) LinkedList();
Container b = new(MallocAllocator) LinkedList();
Container c = new(GC) LinkedList();

When adding an item to the above containers the relevant allocator will
enact its policy about intermixing with other allocators - by default
the item will be copied if it comes from a separate allocator. I don't
see anything here that forces the use of structs instead of classes.

(Please don't overquote. It took me a million years to scroll all the way down on my phone. Thanks.)

This is an alluring proposition but it's a lot more difficult than one might think. The problem is the entire container design is different if e.g. using refcounting vs. classic garbage collection.

You may want to try designing a simple container and isolate all memory/lifetime-specific issues into an allocator. See what allocator interface you come up with. I was unable to solve this problem, but it's possible it has a solution.


Andrei

Reply via email to