Re: Proper way to work around `Invalid memory operation`?

2016-09-29 Thread Kagamin via Digitalmars-d-learn
On Sunday, 25 September 2016 at 16:07:12 UTC, Matthias Klumpp wrote: Hello! I have a class similar to this one: ``` class Dummy { private: string tmpDir; public: this (string fname) { tmpDir = buildPath ("/tmp", fname.baseName); std.file.mkdirRecurse (tmpDir);

Re: Proper way to work around `Invalid memory operation`?

2016-09-27 Thread Kapps via Digitalmars-d-learn
On Sunday, 25 September 2016 at 16:07:12 UTC, Matthias Klumpp wrote: Hello! I have a class similar to this one: ``` class Dummy { private: string tmpDir; public: this (string fname) { tmpDir = buildPath ("/tmp", fname.baseName); std.file.mkdirRecurse (tmpDir);

Re: Proper way to work around `Invalid memory operation`?

2016-09-26 Thread ketmar via Digitalmars-d-learn
On Monday, 26 September 2016 at 09:43:02 UTC, Nemanja Boric wrote: On Sunday, 25 September 2016 at 16:07:12 UTC, Matthias Klumpp wrote: At time, I work around this bug by calling close() manually at the appropriate time, but this feel like a rather poor solution. Cheers, Matthias

Re: Proper way to work around `Invalid memory operation`?

2016-09-26 Thread Nemanja Boric via Digitalmars-d-learn
On Sunday, 25 September 2016 at 16:07:12 UTC, Matthias Klumpp wrote: At time, I work around this bug by calling close() manually at the appropriate time, but this feel like a rather poor solution. Cheers, Matthias That's not a poor solution, but rather a much better solution if you rely

Re: Proper way to work around `Invalid memory operation`?

2016-09-25 Thread ketmar via Digitalmars-d-learn
use rc scheme (a-la std.stdio.File is using), so dtor will be called deterministically, not by GC. here is the sample of that, which creates lockfile. you can use RC implementation like that for many other things. it is mostly as cheap as class: the main struct is only size_t aka pointer (like

Proper way to work around `Invalid memory operation`?

2016-09-25 Thread Matthias Klumpp via Digitalmars-d-learn
Hello! I have a class similar to this one: ``` class Dummy { private: string tmpDir; public: this (string fname) { tmpDir = buildPath ("/tmp", fname.baseName); std.file.mkdirRecurse (tmpDir); } ~this () { close (); } void close ()