std.process: spawnProcess
Russel Winder
russel at winder.org.uk
Sat Sep 8 09:34:54 UTC 2018
On Sat, 2018-09-08 at 02:38 +0000, Basile B. via Digitalmars-d-learn wrote:
>
[…]
> You can wrap in a Process struct or class and take advantage of
> the destructor to do that. Assuming you write standard GC-ed code
> the destructor should be called at the end or if you free
> manually the resources.
But as with other GC systems, there is no guarantee that the destructor will
ever be called, or perhaps there is something here that gets round that?
> example API:
>
> struct SpawnedProcess
> {
> private:
> Pid pid;
> public:
> this();
> void execute();
> void terminate();
> bool running();
> ~this(){ if (running) terminate();}
> }
struct or class? Given it is of necessity a heap located value I'd have used
class, but is struct better here?
> P.S: i just see that in my own Process class i forgot to do that.
--
Russel.
===========================================
Dr Russel Winder t: +44 20 7585 2200
41 Buckmaster Road m: +44 7770 465 077
London SW11 1EN, UK w: www.russel.org.uk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20180908/f2a99ad5/attachment-0001.sig>
More information about the Digitalmars-d-learn
mailing list