Exemplo n.º 1
0
        public void run5()
        {
            FreePool p = new FreePool(2);

            MyPoolRunnable r1 = new MyPoolRunnable(Q2, false);

            Assert.IsFalse(r1.done);
            Assert.IsNull(r1.ex);

            MyPoolRunnable r2 = new MyPoolRunnable(Q2, false);

            Assert.IsFalse(r2.done);
            Assert.IsNull(r2.ex);

            p.Run(r1.run, r1.exception);
            p.Run(r2.run, r2.exception);

            Thread.Sleep(Q1);
            Assert.IsFalse(r1.done);
            Assert.IsNull(r1.ex);

            Assert.IsFalse(r2.done);
            Assert.IsNull(r2.ex);

            Thread.Sleep(Q3);
            Assert.IsTrue(r1.done);
            Assert.IsNull(r1.ex);

            Assert.IsTrue(r2.done);
            Assert.IsNull(r2.ex);
        }
Exemplo n.º 2
0
        public void join1()
        {
            // free pool thread count exceeded or pool closed
            FreePool p = new FreePool(2);

            p.Join();

            MyPoolRunnable r = new MyPoolRunnable(0, false);

            p.Run(r.run, r.exception);
        }
Exemplo n.º 3
0
        public void join2()
        {
            FreePool p = new FreePool(2);

            MyPoolRunnable r = new MyPoolRunnable(0, false);

            Assert.IsFalse(r.done);
            Assert.IsNull(r.ex);
            p.Run(r.run, r.exception);
            Thread.Sleep(Q2);
            Assert.IsTrue(r.done);
            Assert.IsNull(r.ex);
            p.Join();
        }
Exemplo n.º 4
0
        public void run3()
        {
            FreePool p = new FreePool(2);

            MyPoolRunnable r = new MyPoolRunnable(0, true);

            Assert.IsFalse(r.done);
            Assert.IsNull(r.ex);

            p.Run(r.run, r.exception);

            Thread.Sleep(Q1);
            Assert.IsFalse(r.done);
            Assert.IsNotNull(r.ex);
        }
Exemplo n.º 5
0
        public void run2()
        {
            FreePool p = new FreePool(2);

            for (int i = 0; i < 100; i++)
            {
                MyPoolRunnable r = new MyPoolRunnable(0, false);
                Assert.IsFalse(r.done);
                Assert.IsNull(r.ex);

                p.Run(r.run, r.exception);

                Thread.Sleep(Q1);
                Assert.IsTrue(r.done);
                Assert.IsNull(r.ex);
            }
        }
Exemplo n.º 6
0
        public void run6()
        {
            // free pool thread count exceeded
            FreePool p = new FreePool(2);

            MyPoolRunnable r1 = new MyPoolRunnable(Q2, false);

            Assert.IsFalse(r1.done);
            Assert.IsNull(r1.ex);

            MyPoolRunnable r2 = new MyPoolRunnable(Q2, false);

            Assert.IsFalse(r2.done);
            Assert.IsNull(r2.ex);

            MyPoolRunnable r3 = new MyPoolRunnable(Q2, false);

            Assert.IsFalse(r3.done);
            Assert.IsNull(r3.ex);

            p.Run(r1.run, r1.exception);
            p.Run(r2.run, r2.exception);
            p.Run(r3.run, r3.exception);
        }