-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdoppl_shared_member.hpp
More file actions
39 lines (31 loc) · 844 Bytes
/
Copy pathdoppl_shared_member.hpp
File metadata and controls
39 lines (31 loc) · 844 Bytes
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
31
32
33
34
35
36
37
38
39
#ifndef _DOPPL_SHARED_MEMBER
#define _DOPPL_SHARED_MEMBER
#include "doppl_libs.hpp"
namespace doppl {
template<typename T>
class shared {
private:
T member;
std::mutex m;
public:
//Asignment for member types
template<typename V, typename... Vs>
shared<T>& set(V& v, Vs&... args) {
std::lock_guard<std::mutex> lock(m);
member.set(v, args...);
return *this;
};
//Assignment for literals
shared<T>& set(decltype(member.get())& v) {
std::lock_guard<std::mutex> lock(m);
member.set(v);
return *this;
};
//Forward get
auto get() -> decltype(member.get()) {
std::lock_guard<std::mutex> lock(m);
return member.get();
};
};
};
#endif