blob: bb3395996b4bbf6770c2ae434d2f4cdaf24cbf40 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#ifndef MBGL_UTIL_EXCLUSIVE
#define MBGL_UTIL_EXCLUSIVE
#include <memory>
#include <mutex>
namespace mbgl {
namespace util {
template <class T>
class exclusive {
public:
inline exclusive(T* val, std::unique_ptr<std::lock_guard<std::mutex>> mtx) : ptr(val), lock(std::move(mtx)) {}
inline T* operator->() { return ptr; }
inline const T* operator->() const { return ptr; }
inline T* operator*() { return ptr; }
inline const T* operator*() const { return ptr; }
private:
T *ptr;
std::unique_ptr<std::lock_guard<std::mutex>> lock;
};
} // end namespace util
} // end namespace mbgl
#endif
|