-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathatomic_copy.cpp
More file actions
40 lines (29 loc) · 746 Bytes
/
atomic_copy.cpp
File metadata and controls
40 lines (29 loc) · 746 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
40
#include <iostream>
#include <atomic>
#include <cstring>
using namespace std;
class vmdkcachestats {
public:
vmdkcachestats() { }
//vmdkcachestats(uint64_t arg1) : cnt_(arg1) {}
#if 0
vmdkcachestats& operator=(volatile vmdkcachestats& other) {
atomic_store(&cnt_, atomic_load(&other.cnt_));
uint64_t tmp = atomic_load(&other.cnt_);
cout << "moving into non-atomic from atomic " << tmp << '\n';
}
#endif
struct {
std::atomic<uint64_t> cnt_;
} stats_;
};
int main() {
vmdkcachestats* st = new vmdkcachestats();
auto & stats_ref = st->stats_;
st->stats_.cnt_ = 10;
cout << stats_ref.cnt_ << endl;
//vmdkcachestats obj2, obj1(10);
//obj2 = obj1;
//cout << "final val is " << obj2.cnt_ << '\n';
return 0;
}