NeuralEngine A Game Engine with embeded Machine Learning algorithms based on Gaussian Processes. |

NeThreadSafeMap.h
1
11#pragma once
12
13#include <NeCoreLib.h>
14#include <map>
15#include <mutex>
16#include <vector>
17
18 namespace NeuralEngine
19{
20
21 template <typename Key, typename Value>
22 class ThreadSafeMap
23 {
24 public:
25 // Construction and destruction.
26 virtual ~ThreadSafeMap();
27 ThreadSafeMap();
28
29 // All the operations are thread-safe.
30 bool HasElements() const;
31 bool Exists(Key key) const;
32 void Insert(Key key, Value value);
33 bool Remove(Key key, Value& value);
34 void RemoveAll();
35 bool Get(Key key, Value& value) const;
36 void GatherAll(std::vector<Value>& values) const;
37
38 protected:
39 std::map<Key, Value> mMap;
40 mutable std::mutex mMutex;
41 };
42#include "NeThreadSafeMap.inl"
43}
NeuralEngine::ThreadSafeMap
Definition: NeThreadSafeMap.h:23
NeuralEngine::ThreadSafeMap::~ThreadSafeMap
virtual ~ThreadSafeMap()
Definition: NeThreadSafeMap.inl:12
NeuralEngine
Definition: NeArray2.h:18