On Saturday, 29 August 2015 at 13:14:26 UTC, ponce wrote:
class MyResource { void* handle;this() { handle = create_handle(); } ~this() {if (handle != null) // must support repeated calls for the case (called by .destroy + called by GC later){ ensureNotInGC("MyResource"); free_handle(handle); } } }
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?
