Revised synchronization

This commit is contained in:
Paul-Louis Ageneau
2019-12-16 10:45:00 +01:00
parent 5a8725dac1
commit e5a19f85ed
11 changed files with 138 additions and 95 deletions

View File

@ -57,13 +57,13 @@ public:
~synchronized_callback() { *this = nullptr; }
synchronized_callback &operator=(std::function<void(P...)> func) {
std::lock_guard<std::recursive_mutex> lock(mutex);
std::lock_guard lock(mutex);
callback = func;
return *this;
}
void operator()(P... args) const {
std::lock_guard<std::recursive_mutex> lock(mutex);
std::lock_guard lock(mutex);
if (callback)
callback(args...);
}