diff --git a/Aufgabe3/ConsoleApplication1/Buffer.cs b/Aufgabe3/ConsoleApplication1/Buffer.cs index 816b685867f4c557f4efc472a3d624aede3567c3..bc30db5b211f49c64c9345b3bf4399ad86cc95b2 100644 --- a/Aufgabe3/ConsoleApplication1/Buffer.cs +++ b/Aufgabe3/ConsoleApplication1/Buffer.cs @@ -4,31 +4,40 @@ using System.Threading; namespace ConsoleApplication1 { + /// <summary> + /// Created a Class Buffer that contains a Queue which represents the "Garage". + /// The Queue is limited by the size + /// </summary> + public class Buffer { private Queue<Car> carQueue; private int size = 10; private Mutex mutex; + // The Buffer has a Mutex and a Queue public Buffer() { mutex = new Mutex(); carQueue = new Queue<Car>(); } + // This functions adds a Car object into the Queue public void push(Car c) { + // Throws an Exception if the Buffer size equals size if (carQueue.Count == size) { throw new Exception("Buffer full"); } - - + // Adds the passed Car object with the default Enqueue method carQueue.Enqueue(c); } + // removes a Car from the Queue and returns the Queue public Car pop() { + // Throws an Exception if the Buffer size equals 0 if (carQueue.Count == 0) { throw new Exception("Buffer empty"); @@ -37,6 +46,7 @@ namespace ConsoleApplication1 return carQueue.Dequeue(); } + // returns a wheather the Queue is full or not public bool full() { bool isFull = false; @@ -48,6 +58,7 @@ namespace ConsoleApplication1 return isFull; } + // returns a wheather the Queue is empty or not public bool empty() { if (carQueue.Count == 0) @@ -58,11 +69,11 @@ namespace ConsoleApplication1 return false; } + // returns the mutex public Mutex getMutex() { return this.mutex; } - } } diff --git a/Aufgabe3/ConsoleApplication1/Producer.cs b/Aufgabe3/ConsoleApplication1/Producer.cs index dbb11500b3e0f95ad15330edb96e364cf43e96ac..9301e9477b451a7d5bba67cfc728877607a012d6 100644 --- a/Aufgabe3/ConsoleApplication1/Producer.cs +++ b/Aufgabe3/ConsoleApplication1/Producer.cs @@ -3,7 +3,6 @@ using System.Threading; namespace ConsoleApplication1 { - public class Producer {