On Wednesday, 1 September 2021 at 16:02:47 UTC, james.p.leblanc wrote:
Dear D-ers,

For simple plotting using a gnuplot process, I have created a singleton object (a stripped
down minimal working example is below.)

[...]

**However, those wrapper functions in the gnuplot_mod module looks a bit silly.**

[...]

Any suggestions on a better way are greatly appreciated.

Best Regards,
James

hello, I'd suggest this:

```d
shared static this() {
    get(); // cache instance before main(){}
           // to get rid of the synchronized() stmt
}

static Gnuplot get() {
    __gshared Gnuplot instance;
    return instance ? instance : (instance = new Gnuplot());
}
```

Reply via email to