GC-proof resource classes
ponce via Digitalmars-d
digitalmars-d at puremagic.com
Sun Aug 30 06:12:08 PDT 2015
On Sunday, 30 August 2015 at 11:45:36 UTC, skoppe wrote:
> On Sunday, 30 August 2015 at 09:54:31 UTC, ponce wrote:
>> On Saturday, 29 August 2015 at 16:12:52 UTC, skoppe wrote:
>>>
>>> I don't think it is a good idea to call create_handle() in
>>> the constructor. Why not just pass a handle into the Resource?
>>
>> This isn't related to the topic.
>
> By putting create_handle in the constructor, you inevitably end
> up putting free_handle in some (destructor) function. The
> problems you are having might be different/easier when you make
> something else do the (de)construction. Like, say, a
> ResourceManager.
The handle is not important, the idiom applies equally to any
class with a non-trivial destructor.
More information about the Digitalmars-d
mailing list