Eigener Buffer für Producer-Consumer Lösung.

Noch unvollständig
This commit is contained in:
Daniel Herrmann
2014-04-16 14:28:01 +02:00
parent 32048c3d84
commit cc268a3983
4 changed files with 49 additions and 19 deletions

35
src/Buffer.cs Normal file
View File

@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace WorldOfPeacecraft
{
public class Buffer
{
private Queue<string> RawBuffer = new Queue<string>();
private AutoResetEvent BufferFilledEvent = new AutoResetEvent (false);
int size;
public Buffer(int size)
{
this.size=size;
}
public void AddToBuffer (string s)
{
if (RawBuffer.Count >= size){
}
else{
lock (RawBuffer) {
RawBuffer.Enqueue (s);
BufferFilledEvent.Set ();
}
}
}
}
}