On Monday, 15 September 2014 at 02:26:19 UTC, Andrei Alexandrescu wrote:
The road there is long, but it starts with the proverbial first step.

An unrelated question, but how will reference counting work with classes?

I've recently switched my networking library's raw memory wrapper to reference counting (previously it just relied on the GC for cleanup), and it was going well until I've hit a brick wall.

The thing with reference counting is it doesn't seem to make sense to do it half-way. Everything across the ownership chain must be reference counted, because otherwise the non-ref-counted link will hold on to its ref-counted child objects forever (until the next GC cycle).

In my case, the classes in my applications were holding on to my reference-counted structs, and wouldn't let go until they were eventually garbage-collected. I can't convert the classes to structs because I need their inheritance/polymorphism, and I don't see an obvious way to refcount classes (RefCounted explicitly does not support classes).

Am I overlooking something?

Reply via email to