Created
June 21, 2019 17:41
-
-
Save jdee/e44d7f0b15fe9a89d0b3bd13a277b314 to your computer and use it in GitHub Desktop.
Poco mutexes and scoped locks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Poco/Mutex.h> | |
using namespace Poco; | |
class MyClass { | |
public: | |
bool getData() const { | |
Mutex::ScopedLock _l(_mutex); | |
return _data; | |
} | |
void setData(bool data) { | |
Mutex::ScopedLock _l(_mutex); | |
_data = data; | |
} | |
private: | |
Mutex mutable _mutex; | |
bool volatile _data; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment