Skip to content

Instantly share code, notes, and snippets.

@jdee
Created June 21, 2019 17:41
Show Gist options
  • Save jdee/e44d7f0b15fe9a89d0b3bd13a277b314 to your computer and use it in GitHub Desktop.
Save jdee/e44d7f0b15fe9a89d0b3bd13a277b314 to your computer and use it in GitHub Desktop.
Poco mutexes and scoped locks
#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