Esempio n. 1
0
        public void NestingOrElseTest()
        {
            var buffer1 = new STM.Collections.Queue <int>();
            var buffer2 = new STM.Collections.Queue <int>();

            buffer2.Enqueue(10);

            var result = STMSystem.Atomic(() =>
            {
                if (buffer1.Count == 0)
                {
                    STMSystem.Retry();
                }

                return(buffer1.Dequeue());
            },
                                          () =>
            {
                if (buffer2.Count == 0)
                {
                    STMSystem.Retry();
                }

                return(buffer2.Dequeue());
            });

            Assert.IsTrue(result == 10);
            Assert.IsTrue(buffer1.Count == 0);
            Assert.IsTrue(buffer2.Count == 0);
        }
Esempio n. 2
0
 public void Setup()
 {
     _queue = new STM.Collections.Queue <int>();
 }