Yes agree that the poly Database is broken - it isn't reference counted and I will fix that.

Your sample code had me wondering if I am missing something else, but I can't see another issue yet. I think the use of classes would definitely lead to problems with resources being freed out of order or too late.

As far as memory management options, my plan is to work allocators into the design and that would seem to provide a lot of options. I'm having a problem at the moment with MallocAllocator's shared interface. I'm not sure why it's shared since malloc/free are thread safe and I can't seem to cast away the shared. I'm sure there is a reason.

erik


On Wednesday, 2 March 2016 at 03:07:54 UTC, Rikki Cattermole wrote:
Okay I've found a problem.

Here is some code demonstrating it.
http://dpaste.dzfl.pl/022c9e610a18

Now take a look again at Database https://github.com/cruisercoder/dstddb/blob/master/src/std/database/poly/database.d#L37

Do you see the problem?
The solution is simple.

The client database type can be a struct or a class. It doesn't matter too much (assuming you're going the way of ranges). But the intermediary representation must be on the heap and should probably use the constructor and not a static create method to get it. This way people can use other memory management solutions and construct it however they like.


Reply via email to