Re: Best way to manage non-memory resources in current D, ex: database handles.
Kagamin via Digitalmars-d-learn Thu, 09 Mar 2017 08:41:47 -0800
Unique is probably not good for database connection: you then
can't have connection in two variables, also if it holds a
reference to GC-allocated memory, it can't be put to GC-allocated
memory, since when that GC-allocated memory is collected, Unique
will try to destroy its possibly already freed object resulting
in use after free. RefCounted is ok, it has calls to GC in order
to be scanned for GC references, though destructors during
collection are called in a different thread, so the counter can
be decremented incorrectly. Phobos tends to have specialized
types like File and RcString, but they have the same problem with
reference counting during collections.
- Re: Best way to manage non-memory re... Adam D. Ruppe via Digitalmars-d-learn
- Re: Best way to manage non-memo... Chad Joan via Digitalmars-d-learn
- Re: Best way to manage non-memo... Kagamin via Digitalmars-d-learn
- Re: Best way to manage non-... Kagamin via Digitalmars-d-learn