general: Use deducation guides for std::lock_guard and std::unique_lock
Since C++17, the introduction of deduction guides for locking facilities means that we no longer need to hardcode the mutex type into the locks themselves, making it easier to switch mutex types, should it ever be necessary in the future.
This commit is contained in:
parent
d5bcb45b2a
commit
21c71d21ae
21 changed files with 124 additions and 122 deletions
|
@ -65,14 +65,14 @@ void AnnounceMultiplayerSession::Stop() {
|
|||
|
||||
AnnounceMultiplayerSession::CallbackHandle AnnounceMultiplayerSession::BindErrorCallback(
|
||||
std::function<void(const Common::WebResult&)> function) {
|
||||
std::lock_guard<std::mutex> lock(callback_mutex);
|
||||
std::lock_guard lock(callback_mutex);
|
||||
auto handle = std::make_shared<std::function<void(const Common::WebResult&)>>(function);
|
||||
error_callbacks.insert(handle);
|
||||
return handle;
|
||||
}
|
||||
|
||||
void AnnounceMultiplayerSession::UnbindErrorCallback(CallbackHandle handle) {
|
||||
std::lock_guard<std::mutex> lock(callback_mutex);
|
||||
std::lock_guard lock(callback_mutex);
|
||||
error_callbacks.erase(handle);
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ void AnnounceMultiplayerSession::AnnounceMultiplayerLoop() {
|
|||
UpdateBackendData(room);
|
||||
Common::WebResult result = backend->Update();
|
||||
if (result.result_code != Common::WebResult::Code::Success) {
|
||||
std::lock_guard<std::mutex> lock(callback_mutex);
|
||||
std::lock_guard lock(callback_mutex);
|
||||
for (auto callback : error_callbacks) {
|
||||
(*callback)(result);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue