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

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jun 27 09:22:14 PDT 2017


On 6/27/17 12:16 PM, Steven Schveighoffer wrote:
> On 6/27/17 11:24 AM, Steven Schveighoffer wrote:
>> On 6/27/17 9:25 AM, Guillaume Piolat wrote:
> 
>>> That's how the GC-proof resource class came to existence, after many 
>>> destruction bugs, and it let's you use the GC as a detector for 
>>> non-deterministic destruction. I miss it in @nogc :)
>>>
>>> https://p0nce.github.io/d-idioms/#GC-proof-resource-class
>>
>> There are definitely better ways to do this than trying to allocate 
>> and catching an error. The GC knows the GC is running, use that 
>> mechanism instead :)
> 
> https://github.com/dlang/druntime/blob/master/src/gc/gcinterface.d#L189
> https://github.com/dlang/druntime/blob/master/src/core/memory.d#L150
> 
> Apparently that info is limited to the core.memory package. But it's 
> extern(C), so declaring the prototype should work. Should be much more 
> efficient than allocating a byte (which I see you don't delete if it 
> works), and catching an error.

Just added this enhancement to publicize this function: 
https://issues.dlang.org/show_bug.cgi?id=17563

-Steve


More information about the Digitalmars-d-learn mailing list