Future of SafeRefCounted
Sebastiaan Koppe
mail at skoppe.eu
Mon Feb 24 19:20:54 UTC 2025
On Monday, 24 February 2025 at 17:18:55 UTC, Dukc wrote:
> On Sunday, 23 February 2025 at 20:02:03 UTC, Dennis wrote:
>> On the other hand, I think reference counting sucks in
>> general, and see little value in using it in Phobos.
>> Especially in functions like dirEntires, as if that is going
>> to be called a lot in performance critical real-time code.
>
> I disagree, reference counting is a great tool for this use
> case. Not because of the memory, but because if the directory
> handles. Were the `dirEntries` implementation garbage
> collected, the directory handles would get released only when
> the collection happens, which could never happen if the program
> doesn't use much RAM.
For resource management with deterministic lifecycle, I usually
prefer non-copyable structs with refs. Only in the rare case when
they need to be accessible in multiple parts of the code would I
resort to ref counting.
More information about the Digitalmars-d
mailing list