Fixed size queue which automatically dequeues old values upon new enqueues

I would write a wrapper class that on Enqueue would check the Count and then Dequeue when the count exceeds the limit. public class FixedSizedQueue<T> { readonly ConcurrentQueue<T> q = new ConcurrentQueue<T>(); private object lockObject = new object(); public int Limit { get; set; } public void Enqueue(T obj) { q.Enqueue(obj); lock (lockObject) { T … Read more

Create Named Pipe C++ Windows

You cannot create a named pipe by calling CreateFile(..). Have a look at the pipe examples of the MSDN. Since these examples are quite complex I’ve quickly written a VERY simple named pipe server and client. int main(void) { HANDLE hPipe; char buffer[1024]; DWORD dwRead; hPipe = CreateNamedPipe(TEXT(“\\\\.\\pipe\\Pipe”), PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, // … Read more

Fixed size queue which automatically dequeues old values upon new enques

I would write a wrapper class that on Enqueue would check the Count and then Dequeue when the count exceeds the limit. public class FixedSizedQueue<T> { ConcurrentQueue<T> q = new ConcurrentQueue<T>(); private object lockObject = new object(); public int Limit { get; set; } public void Enqueue(T obj) { q.Enqueue(obj); lock (lockObject) { T overflow; … Read more