On Monday, 21 November 2022 at 11:56:59 UTC, Ali Çehreli wrote:
..
You took the question as whether to define them for class hierarchies, safety-critical systems, etc.

Ali

Or even in a very, very simple counter class:


public synchronized class Counter
{
    static import core.atomic;

    private:
        int count = 0;

    public:
        void incrementCounter()
        {
            if ((count + 1) < 0)
            {
                // you might want to handle this
            }
            else
                core.atomic.atomicOp!"+="(this.count, 1);
        }

        int displayCounter()
        {
            return count;
        }
}

Reply via email to