public void GetSet()
        {
            int mark;
            AtomicStamped <T> ai = new AtomicStamped <T>(one, 0);

            Assert.AreEqual(one, ai.Value);
            Assert.AreEqual(0, ai.Stamp);
            Assert.AreEqual(one, ai.GetValue(out mark));
            Assert.AreEqual(0, mark);
            ai.SetNewAtomicValue(two, 0);
            Assert.AreEqual(two, ai.Value);
            Assert.AreEqual(0, ai.Stamp);
            Assert.AreEqual(two, ai.GetValue(out mark));
            Assert.AreEqual(0, mark);
            ai.SetNewAtomicValue(one, 1);
            Assert.AreEqual(one, ai.Value);
            Assert.AreEqual(1, ai.Stamp);
            Assert.AreEqual(one, ai.GetValue(out mark));
            Assert.AreEqual(1, mark);

            ai.SetNewAtomicValue(one, 1);
            Assert.AreEqual(one, ai.Value);
            Assert.AreEqual(1, ai.Stamp);
            Assert.AreEqual(one, ai.GetValue(out mark));
            Assert.AreEqual(1, mark);
        }
        public void AttemptStamp()
        {
            int mark;
            AtomicStamped <T> ai = new AtomicStamped <T>(one, 0);

            Assert.AreEqual(0, ai.Stamp);
            Assert.IsTrue(ai.AttemptStamp(one, 1));
            Assert.AreEqual(1, ai.Stamp);
            Assert.AreEqual(one, ai.GetValue(out mark));
            Assert.AreEqual(1, mark);
        }
        public void CompareAndSet()
        {
            int mark;
            AtomicStamped <T> ai = new AtomicStamped <T>(one, 0);

            Assert.AreEqual(one, ai.GetValue(out mark));
            Assert.AreEqual(0, ai.Stamp);
            Assert.AreEqual(0, mark);

            Assert.IsTrue(ai.CompareAndSet(one, two, 0, 0));
            Assert.AreEqual(two, ai.GetValue(out mark));
            Assert.AreEqual(0, mark);

            Assert.IsTrue(ai.CompareAndSet(two, m3, 0, 1));
            Assert.AreEqual(m3, ai.GetValue(out mark));
            Assert.AreEqual(1, mark);

            Assert.IsFalse(ai.CompareAndSet(two, m3, 1, 1));
            Assert.AreEqual(m3, ai.GetValue(out mark));
            Assert.AreEqual(1, mark);
        }
        public void WeakCompareAndSet()
        {
            int mark;
            AtomicStamped <T> ai = new AtomicStamped <T>(one, 0);

            Assert.AreEqual(one, ai.GetValue(out mark));
            Assert.AreEqual(0, ai.Stamp);
            Assert.AreEqual(0, mark);

            while (!ai.WeakCompareAndSet(one, two, 0, 0))
            {
            }

            Assert.AreEqual(two, ai.GetValue(out mark));
            Assert.AreEqual(0, mark);

            while (!ai.WeakCompareAndSet(two, m3, 0, 1))
            {
            }

            Assert.AreEqual(m3, ai.GetValue(out mark));
            Assert.AreEqual(1, mark);
        }