From 8dab865cb66071199557cad257e9c94fde846c1a Mon Sep 17 00:00:00 2001 From: Pontus Fransson Date: Thu, 28 Nov 2013 16:20:50 +0100 Subject: [PATCH] Changed to our own Queue --- Code/Network/NetworkDependencies/PostBox.h | 17 ++++++----------- Code/Network/OysterNetworkClient/ClientMain.cpp | 6 +++--- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/Code/Network/NetworkDependencies/PostBox.h b/Code/Network/NetworkDependencies/PostBox.h index a24cea5e..6b2c2ff8 100644 --- a/Code/Network/NetworkDependencies/PostBox.h +++ b/Code/Network/NetworkDependencies/PostBox.h @@ -6,8 +6,8 @@ ///////////////////////////////////// #include "IPostBox.h" -#include #include "../../Misc/Thread/OysterMutex.h" +#include "../../Misc/ThreadSafeQueue.h" namespace Oyster { @@ -25,8 +25,7 @@ namespace Oyster virtual bool IsFull(); private: - std::queue messages; - OysterMutex mutex; + Oyster::Queue::ThreadSafeQueue messages; }; @@ -44,27 +43,23 @@ namespace Oyster template void PostBox::PostMessage(T& message) { - mutex.LockMutex(); - messages.push(message); - mutex.UnlockMutex(); + messages.Push(message); } template void PostBox::FetchMessage(T& message) { - mutex.LockMutex(); if(IsFull()) { - message = messages.front(); - messages.pop(); + message = messages.Front(); + messages.Pop(); } - mutex.UnlockMutex(); } template bool PostBox::IsFull() { - return !messages.empty(); + return !messages.IsEmpty(); } } } diff --git a/Code/Network/OysterNetworkClient/ClientMain.cpp b/Code/Network/OysterNetworkClient/ClientMain.cpp index 22eb5c40..217773a9 100644 --- a/Code/Network/OysterNetworkClient/ClientMain.cpp +++ b/Code/Network/OysterNetworkClient/ClientMain.cpp @@ -41,7 +41,7 @@ int main() //test queue //----------------------------------------- - Oyster::Queue::IQueue *test = new Oyster::Queue::ThreadSafeQueue(); + /*Oyster::Queue::IQueue *test = new Oyster::Queue::ThreadSafeQueue(); Oyster::Queue::IQueue *test2 = new Oyster::Queue::ThreadSafeQueue(); for(int i = 0; i < 100; i++) @@ -91,8 +91,8 @@ int main() cout << test->Front() << " " << test2->Front() <