コード例 #1
0
ファイル: FutureTests.cs プロジェクト: smartcaveman/AjSharp
        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
ファイル: FutureTests.cs プロジェクト: smartcaveman/AjSharp
        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);
        }