Browse Source

Small fixes to synchronized_callback

Paul-Louis Ageneau 5 years ago
parent
commit
0f0047729b
1 changed files with 5 additions and 2 deletions
  1. 5 2
      include/rtc/include.hpp

+ 5 - 2
include/rtc/include.hpp

@@ -68,7 +68,7 @@ public:
 
 	synchronized_callback &operator=(std::function<void(P...)> func) {
 		std::lock_guard lock(mutex);
-		callback = func;
+		callback = std::move(func);
 		return *this;
 	}
 
@@ -78,7 +78,10 @@ public:
 			callback(args...);
 	}
 
-	operator bool() const { return callback ? true : false; }
+	operator bool() const {
+		std::lock_guard lock(mutex);
+		return callback ? true : false;
+	}
 
 private:
 	std::function<void(P...)> callback;