Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Volume
- {
- atomic<int> _width;
- atomic<int> _height;
- atomic<int> _depth;
- public:
- int computeValue() {return (_width*_height*_depth);}
- void SetInternals(int w, int h, int d) {_height=h;_width=w;_depth=d;}
- };
- f->SetInternals(42, 100, 200);
- int something_important = f->computeValue();
- class Volume
- {
- int _width;
- int _height;
- int _depth;
- mutex _mutex;
- public:
- int computeValue() {
- lock_guard<mutex> lck(_mutex);
- int result = _width*_height*_depth);
- return result;
- }
- void SetInternals(int w, int h, int d) {
- lock_guard<mutex> lck(_mutex);
- _height=h;_width=w;_depth=d;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement