NeuralEngine
A Game Engine with embeded Machine Learning algorithms based on Gaussian Processes.
NeThreadSafeQueue.h
1
11#pragma once
12
13#include <NeCoreLib.h>
14#include <mutex>
15#include <queue>
16
17namespace NeuralEngine
18{
19
20 template <typename Element>
22 {
23 public:
24 // Construction and destruction.
25 virtual ~ThreadSafeQueue();
26 ThreadSafeQueue(size_t maxNumElements = 0);
27
28 // All the operations are thread-safe.
29 size_t GetMaxNumElements() const;
30 size_t GetNumElements() const;
31 bool Push(Element const& element);
32 bool Pop(Element& element);
33
34 protected:
35 size_t mMaxNumElements;
36 std::queue<Element> mQueue;
37 mutable std::mutex mMutex;
38 };
39#include "NeThreadSafeQueue.inl"
40}