Пример #1
0
        public void CreateFutureSetAndGetValue()
        {
            Future future = new Future();

            future.SetValue(1);

            object result = future.GetValue();

            Assert.IsNotNull(result);
            Assert.AreEqual(1, result);

            result = future.GetValue();

            Assert.IsNotNull(result);
            Assert.AreEqual(1, result);
        }
Пример #2
0
 private int[] MergeItems(Tuple t, Future sortedGreater, Future sortedLess)
 {
     List<int> result = new List<int>();
     result.AddRange(sortedLess.GetValue<int[]>());
     result.AddRange(t.Eq);
     result.AddRange(sortedGreater.GetValue<int[]>());
     return result.ToArray();
 }
Пример #3
0
        private int[] MergeItems(Tuple t, Future sortedGreater, Future sortedLess)
        {
            List <int> result = new List <int>();

            result.AddRange(sortedLess.GetValue <int[]>());
            result.AddRange(t.Eq);
            result.AddRange(sortedGreater.GetValue <int[]>());
            return(result.ToArray());
        }
Пример #4
0
        public void CreateFutureGetAndSetValue()
        {
            Future           future   = new Future();
            ManualResetEvent handle   = new ManualResetEvent(false);
            bool             executed = false;

            Thread thread = new Thread(new ThreadStart(() => { handle.WaitOne(); executed = true;  future.SetValue(1); }));

            thread.Start();

            Assert.IsFalse(executed);
            Thread.Sleep(100);
            Assert.IsFalse(executed);

            handle.Set();

            object result = future.GetValue();

            Assert.IsTrue(executed);

            Assert.IsNotNull(result);
            Assert.AreEqual(1, result);
        }