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
18namespace NeuralEngine
19{
20
21 template <typename Key, typename Value>
23 {
24 public:
25 // Construction and destruction.
26 virtual ~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}