Пример #1
0
        public Producer(BoundedBuffer buffer, int howManytoproduce)
        {
            this._max = howManytoproduce;
            this._buffer = buffer;
            

        }
Пример #2
0
        public Consumer(BoundedBuffer buffer)
        {
           
            this._buffer = buffer;
           

        }
Пример #3
0
        static void Main(string[] args)
        {
            BoundedBuffer buf = new BoundedBuffer(4);

            Producer prod = new Producer(buf, 10);
            Consumer con = new Consumer(buf, 10);

            Parallel.Invoke(prod.Run, con.Run);
        }
Пример #4
0
        static void Main()
        {
            var buf = new BoundedBuffer(4);

            var prod = new Producer(buf, 10);
            var con  = new Consumer(buf);

            Parallel.Invoke(prod.Run, con.Run);
        }
Пример #5
0
        static void Main()
        {
            var buf = new BoundedBuffer(4);

            var prod = new Producer(buf, 10);
            var con = new Consumer(buf);

            Parallel.Invoke(prod.Run, con.Run);
        }
Пример #6
0
        static void Main(string[] args)
        {
            BoundedBuffer buf = new BoundedBuffer(4);

            Producer prod = new Producer(buf, 10);
            Consumer con  = new Consumer(buf, 10);

            Parallel.Invoke(prod.Run, con.Run);
        }
Пример #7
0
        public void TestMethod1()
        {
            BoundedBuffer buf = new BoundedBuffer(4);

            Producer prod = new Producer(buf, 10);
            Consumer con = new Consumer(buf, 10);

            Parallel.Invoke(prod.Run, con.Run);
        }
        static void Main()
        {
            var buf = new BoundedBuffer(4);

            var prod = new Producer(buf, 10);
            var con1 = new Consumer(buf);
            var con2 = new Consumer(buf);

            Parallel.Invoke(prod.Run, con1.Run, con2.Run);

            Console.WriteLine("");
        }
Пример #9
0
        static void Main(string[] args)
        {
            BoundedBuffer buffer = new BoundedBuffer(1);

            Producer prod = new Producer(buffer, 400);
            Consumer cons = new Consumer(buffer);


            //Brug Parallel.Invoke til at køre dem
            Parallel.Invoke(prod.Run, cons.Run);

            Console.ReadLine();
        }
Пример #10
0
        static void Main(string[] args)
        {
            BoundedBuffer buf = new BoundedBuffer(4);

            Producer prod = new Producer(buf, 10);
            Consumer con  = new Consumer(buf);
            Consumer con2 = new Consumer(buf);

            Parallel.Invoke(prod.Run, con.Run, con2.Run);


            Console.WriteLine("--- Done ---");
            Console.ReadKey();
        }
Пример #11
0
        public Comsumer(BoundedBuffer buffer, int howMany)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException();
            }
            if (howMany < 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            _buffer  = buffer;
            _howMany = howMany;

            Thread task = new Thread(Run);

            task.Start();
        }
Пример #12
0
        static void Main(string[] args)
        {
            BoundedBuffer buf = new BoundedBuffer(4);

            Producer prod = new Producer(buf, 10);
            Consumer con = new Consumer(buf);
            Consumer con2 = new Consumer(buf);


            Parallel.Invoke(prod.Run, con.Run, con2.Run);
           


            Console.WriteLine("The buffer was filled {0} times.", buf.NumberOfFills);
            Console.ReadKey();

            ////Parallel.Invoke(
            ////    () => Console.Write(""),
            ////    () => Console.Write("")
            ////    );
        }
Пример #13
0
        static void Main(string[] args)
        {
            BoundedBuffer buf = new BoundedBuffer(4);

            Producer prod = new Producer(buf, 10);
            Consumer con  = new Consumer(buf);
            Consumer con2 = new Consumer(buf);


            Parallel.Invoke(prod.Run, con.Run, con2.Run);



            Console.WriteLine("The buffer was filled {0} times.", buf.NumberOfFills);
            Console.ReadKey();

            ////Parallel.Invoke(
            ////    () => Console.Write(""),
            ////    () => Console.Write("")
            ////    );
        }
Пример #14
0
        static void Main(string[] args)
        {
            BoundedBuffer buffer  = new BoundedBuffer(4); //Brugt til Termination
            BoundedBuffer buffer2 = new BoundedBuffer(4); //Brugt til MiddleMan + Duplicator
            BoundedBuffer buffer3 = new BoundedBuffer(4); //Brugt til Duplicator

            Producer prod = new Producer(buffer, 15);

            //Brugt til Termination
            //Consumer cons = new Consumer(buffer);
            //Consumer cons2 = new Consumer(buffer);

            //Brugt til MiddleMan
            MiddleMan mm     = new MiddleMan(buffer, buffer2); //Tager fra buffer og indsætter i buffer2
            Consumer  consMm = new Consumer(buffer2);

            //Brugt til Duplicator
            Duplicator duplicator = new Duplicator(buffer, buffer2, buffer3); //Tager fra buffer, og sætter værdien ind i både buffer2 & buffer3
            Consumer   consDup    = new Consumer(buffer2);
            Consumer   consDup2   = new Consumer(buffer3);

            //Brug Parallel.Invoke til at køre dem
            Parallel.Invoke(
                () => prod.Run(),  //<- Brugt til Termination, MiddleMan, Duplicator

                //() => cons.Run(), //<- Brugt til Termination
                //() => cons2.Run() //<- Brugt til Termination

                //() => mm.Run(), //<- Brugt til MiddleMan
                //() => consMm.Run() //<- Brugt til MiddleMan

                () => duplicator.Run(), //<- Brugt til Duplicator
                () => consDup.Run(),    //<- Brugt til Duplicator
                () => consDup2.Run()    //<- Brugt til Duplicator
                );
            Console.WriteLine("Done!");
            Console.ReadLine();
        }
Пример #15
0
 public Producer(BoundedBuffer buffer, int howMany)
 {
 }
Пример #16
0
 public Consumer(BoundedBuffer buf, int i)
 {
 }
Пример #17
0
 public Producer(BoundedBuffer obj, int i)
 {
     HowMany = i;
     buf     = obj;
 }
Пример #18
0
 public Consumer(BoundedBuffer buffer)
 {
     _buffer = buffer;
 }
Пример #19
0
 public Consumer(BoundedBuffer obj)
 {
     buf = obj;
 }
Пример #20
0
 public Producer(BoundedBuffer obj, int i)
 {
     HowMany = i;
     buf = obj;
 }
 public Consumer(BoundedBuffer buffer)
 {
     this._buffer = buffer;
     //this.max = expectedAmount;
 }
Пример #22
0
 public Producer(BoundedBuffer buf, int howmany)
 {
     this._buffer = buf;
     this._max    = howmany;
 }
Пример #23
0
 public Producer(BoundedBuffer buf, int i)
 {
 }
Пример #24
0
        public Producer(BoundedBuffer buffer, int produce)
        {
            _buffer = buffer;
            _production = produce;

        }
Пример #25
0
 public Producer(BoundedBuffer buffer, int HowManyToProduce)
 {
     
 }
Пример #26
0
 public Producer(BoundedBuffer buffer, int produce)
 {
     _buffer     = buffer;
     _production = produce;
 }
Пример #27
0
 public Consumer(BoundedBuffer obj)
 {
     buf = obj;
 }
Пример #28
0
 public Duplicator(BoundedBuffer bufferIn, BoundedBuffer bufferOut1, BoundedBuffer bufferOut2)
 {
     _bufferIn   = bufferIn;
     _bufferOut1 = bufferOut1;
     _bufferOut2 = bufferOut2;
 }
Пример #29
0
 public Producer(BoundedBuffer buffer, int howMany)
 {
     
 }
Пример #30
0
 public Consumer(BoundedBuffer buffer)
 {
 }
Пример #31
0
 public MiddleMan(BoundedBuffer bufferIn, BoundedBuffer bufferOut)
 {
     _bufferIn  = bufferIn;
     _bufferOut = bufferOut;
 }
Пример #32
0
 public Producer(BoundedBuffer buffer, int HowManyToProduce)
 {
 }
Пример #33
0
 public Consumer(BoundedBuffer buf)
 {
     this._buffer = buf;
 }
 public Producer(BoundedBuffer buffer, int howManyToProduce)
 {
     this.Max     = howManyToProduce;
     this._buffer = buffer;
 }