Exemple #1
0
        public void Invoke_MaxDegreeOfParallelismIsGreaterThenThreads_RunAllThreadsParallel()
        {
            const int degreeOfParallelism = 10;
            var       manager             = new TotalParallelismThreadManager(degreeOfParallelism, 1000);

            ThreadManagmentTestUtils.TestThatAllThreadsRunInParallel(manager);
        }
Exemple #2
0
        public void Invoke_CheckThatOnlyMaxDegreeOfParallelismThreadsRunParallel(int degreeOfParallelism)
        {
            var startedThreads = new List <int>();
            var manager        = new TotalParallelismThreadManager(degreeOfParallelism, 1000);

            Task.Run(() =>
            {
                for (int i = 0; i < 50; i++)
                {
                    manager.Invoke(() =>
                    {
                        startedThreads.Add(1);
                        return(ThreadManagmentTestUtils.slowAction());
                    }, 1);
                }
            });
            Thread.Sleep(100);

            Assert.AreEqual(degreeOfParallelism, startedThreads.Count);
        }
 public void Invoke_MaxDegreeOfParallelismIsOne_DontRunParallel()
 {
     ThreadManagmentTestUtils.TestThatThreadsRunInSequence(new SequencelThreadManager());
 }
Exemple #4
0
 public void Invoke_MaxDegreeOfParallelismIsOne_DontRunParallel() =>
 ThreadManagmentTestUtils.TestThatThreadsRunInSequence(new TotalParallelismThreadManager(1, 1000));
 public void Invoke_DepthEqualeMaxLevel_RunAllThreadsParallel(int depth, int levels) =>
 ThreadManagmentTestUtils.TestThatAllThreadsRunInParallel(new LevelParallelismThreadManager(levels), depth);
 public void Invoke_DepthGreaterThanMaxLevel_DontRunParallel(int depth, int levels) =>
 ThreadManagmentTestUtils.TestThatThreadsRunInSequence(new LevelParallelismThreadManager(levels), depth);