Advice wanted on garbage collection of sockets for c++ programmer using D

Moritz Maxeiner via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jun 27 16:54:50 PDT 2017


On Tuesday, 27 June 2017 at 23:42:38 UTC, Guillaume Piolat wrote:
> On Tuesday, 27 June 2017 at 18:04:36 UTC, Moritz Maxeiner wrote:
>>
>> Well, technically speaking the `~this` for D classes *is* a 
>> finalizer that you may optionally manually call (e.g. via 
>> destroy).
>> It would be nice, though, to change class `~this` into a 
>> destructor and move the finalization into an extra method like 
>> `finalize`. Write a DIP?
>
> The only sane way out is to prevent the GC from calling 
> constructors.

Do you mean destructors?
If so, that's what I meant with the "technically". If the may GC 
call it (automatically), it's a finalizer, not a destructor (in 
the usual sense, anyway).
- Replace calls by the GC to `~this` with calls to `finalize` (or 
invent some cool other shortened name for the latter)
- Reserve `~this` for being called by deterministic lifetime 
management (std.experimental.allocator.dispose, object.destroy, 
RefCounted, Unique, etc.)



More information about the Digitalmars-d-learn mailing list