#ifndef NETWORK_DEPENDENCIES_POST_BOX_H #define NETWORK_DEPENDENCIES_POST_BOX_H ///////////////////////////////////// // Created by Pontus Fransson 2013 // ///////////////////////////////////// #include "IPostBox.h" #include "../ThreadSafeQueue.h" namespace Oyster { //With this class you can post items to it and then fetch them somewhere else. //It is thread safe beacause of the ThreadSafeQueue. template class PostBox : public IPostBox { public: PostBox(); virtual ~PostBox(); virtual void Post(T message); virtual T Fetch(); virtual bool IsEmpty(); private: Utility::Container::ThreadSafeQueue messages; //Utility::Container::ThreadSafeQueue messages; }; //Implementation of PostBox template PostBox::PostBox() { } template PostBox::~PostBox() { } template void PostBox::Post(T message) { messages.Push(message); } template T PostBox::Fetch() { return messages.Pop(); } template bool PostBox::IsEmpty() { return messages.IsEmpty(); } } #endif