Re: Best way to manage non-memory resources in current D, ex: database handles.

2017-03-09 Thread Kagamin via Digitalmars-d-learn
RefCounted is ok If GC methods it calls are legal during collection.

Re: Best way to manage non-memory resources in current D, ex: database handles.

2017-03-09 Thread Kagamin via Digitalmars-d-learn
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 fr

Re: Best way to manage non-memory resources in current D, ex: database handles.

2017-03-08 Thread Chad Joan via Digitalmars-d-learn
Awesome, thank you! On Thursday, 9 March 2017 at 00:47:48 UTC, Adam D. Ruppe wrote: Now, if you forget to scope(exit), it is OK, the garbage collector WILL get around to it eventually, and it is legal to work with C handles and functions from a destructor. It is only illegal to call D's garbag

Re: Best way to manage non-memory resources in current D, ex: database handles.

2017-03-08 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 8 March 2017 at 23:54:56 UTC, Chad Joan wrote: What's the best way to implement such a range in current D? I'd go with a struct with disabled copying and default construction, then make the destructor free it and the function that returns it populate it. So basically Unique.