Do not receive messages in onMessage is not set

This commit is contained in:
Paul-Louis Ageneau
2019-12-04 12:16:39 +01:00
parent a1df562785
commit 4029a9bb4a
2 changed files with 5 additions and 3 deletions

View File

@ -60,15 +60,17 @@ public:
return *this;
}
void operator()(P... args) {
void operator()(P... args) const {
std::lock_guard<std::recursive_mutex> lock(mutex);
if (callback)
callback(args...);
}
operator bool() const { return callback ? true : false; }
private:
std::function<void(P...)> callback;
std::recursive_mutex mutex;
mutable std::recursive_mutex mutex;
};
}