Remove shared mutex from FML and use the C++17 variants. (flutter/engine#54482)
We used to require this only on iOS because the standard library till iOS 9 didn't have support for this. We have moved past that version. No change on other platforms.
This commit is contained in:
parent
109cffe312
commit
c2992b3273
@ -42563,8 +42563,6 @@ ORIGIN: ../../../flutter/fml/platform/posix/native_library_posix.cc + ../../../f
|
||||
ORIGIN: ../../../flutter/fml/platform/posix/paths_posix.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/fml/platform/posix/posix_wrappers_posix.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/fml/platform/posix/process_posix.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/fml/platform/posix/shared_mutex_posix.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/fml/platform/posix/shared_mutex_posix.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/fml/platform/win/command_line_win.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/fml/platform/win/errors_win.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/fml/platform/win/errors_win.h + ../../../flutter/LICENSE
|
||||
@ -42593,9 +42591,6 @@ ORIGIN: ../../../flutter/fml/synchronization/count_down_latch.cc + ../../../flut
|
||||
ORIGIN: ../../../flutter/fml/synchronization/count_down_latch.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/fml/synchronization/semaphore.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/fml/synchronization/semaphore.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/fml/synchronization/shared_mutex.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/fml/synchronization/shared_mutex_std.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/fml/synchronization/shared_mutex_std.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/fml/synchronization/sync_switch.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/fml/synchronization/sync_switch.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/fml/synchronization/waitable_event.cc + ../../../flutter/LICENSE
|
||||
@ -45400,8 +45395,6 @@ FILE: ../../../flutter/fml/platform/posix/native_library_posix.cc
|
||||
FILE: ../../../flutter/fml/platform/posix/paths_posix.cc
|
||||
FILE: ../../../flutter/fml/platform/posix/posix_wrappers_posix.cc
|
||||
FILE: ../../../flutter/fml/platform/posix/process_posix.cc
|
||||
FILE: ../../../flutter/fml/platform/posix/shared_mutex_posix.cc
|
||||
FILE: ../../../flutter/fml/platform/posix/shared_mutex_posix.h
|
||||
FILE: ../../../flutter/fml/platform/win/command_line_win.cc
|
||||
FILE: ../../../flutter/fml/platform/win/errors_win.cc
|
||||
FILE: ../../../flutter/fml/platform/win/errors_win.h
|
||||
@ -45430,9 +45423,6 @@ FILE: ../../../flutter/fml/synchronization/count_down_latch.cc
|
||||
FILE: ../../../flutter/fml/synchronization/count_down_latch.h
|
||||
FILE: ../../../flutter/fml/synchronization/semaphore.cc
|
||||
FILE: ../../../flutter/fml/synchronization/semaphore.h
|
||||
FILE: ../../../flutter/fml/synchronization/shared_mutex.h
|
||||
FILE: ../../../flutter/fml/synchronization/shared_mutex_std.cc
|
||||
FILE: ../../../flutter/fml/synchronization/shared_mutex_std.h
|
||||
FILE: ../../../flutter/fml/synchronization/sync_switch.cc
|
||||
FILE: ../../../flutter/fml/synchronization/sync_switch.h
|
||||
FILE: ../../../flutter/fml/synchronization/waitable_event.cc
|
||||
|
@ -78,7 +78,6 @@ source_set("fml") {
|
||||
"synchronization/count_down_latch.h",
|
||||
"synchronization/semaphore.cc",
|
||||
"synchronization/semaphore.h",
|
||||
"synchronization/shared_mutex.h",
|
||||
"synchronization/sync_switch.cc",
|
||||
"synchronization/sync_switch.h",
|
||||
"synchronization/waitable_event.cc",
|
||||
@ -136,15 +135,9 @@ source_set("fml") {
|
||||
libs = []
|
||||
|
||||
if (is_ios || is_mac) {
|
||||
sources += [
|
||||
"platform/darwin/concurrent_message_loop_factory.mm",
|
||||
"platform/posix/shared_mutex_posix.cc",
|
||||
]
|
||||
sources += [ "platform/darwin/concurrent_message_loop_factory.mm" ]
|
||||
} else {
|
||||
sources += [
|
||||
"concurrent_message_loop_factory.cc",
|
||||
"synchronization/shared_mutex_std.cc",
|
||||
]
|
||||
sources += [ "concurrent_message_loop_factory.cc" ]
|
||||
}
|
||||
|
||||
if (is_ios || is_mac) {
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "flutter/fml/delayed_task.h"
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "flutter/fml/memory/ref_counted.h"
|
||||
#include "flutter/fml/synchronization/shared_mutex.h"
|
||||
#include "flutter/fml/task_queue_id.h"
|
||||
#include "flutter/fml/task_source.h"
|
||||
#include "flutter/fml/wakeable.h"
|
||||
|
@ -1,35 +0,0 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "flutter/fml/platform/posix/shared_mutex_posix.h"
|
||||
|
||||
#include "flutter/fml/logging.h"
|
||||
|
||||
namespace fml {
|
||||
|
||||
SharedMutex* SharedMutex::Create() {
|
||||
return new SharedMutexPosix();
|
||||
}
|
||||
|
||||
SharedMutexPosix::SharedMutexPosix() {
|
||||
FML_CHECK(pthread_rwlock_init(&rwlock_, nullptr) == 0);
|
||||
}
|
||||
|
||||
void SharedMutexPosix::Lock() {
|
||||
pthread_rwlock_wrlock(&rwlock_);
|
||||
}
|
||||
|
||||
void SharedMutexPosix::LockShared() {
|
||||
pthread_rwlock_rdlock(&rwlock_);
|
||||
}
|
||||
|
||||
void SharedMutexPosix::Unlock() {
|
||||
pthread_rwlock_unlock(&rwlock_);
|
||||
}
|
||||
|
||||
void SharedMutexPosix::UnlockShared() {
|
||||
pthread_rwlock_unlock(&rwlock_);
|
||||
}
|
||||
|
||||
} // namespace fml
|
@ -1,30 +0,0 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef FLUTTER_FML_PLATFORM_POSIX_SHARED_MUTEX_POSIX_H_
|
||||
#define FLUTTER_FML_PLATFORM_POSIX_SHARED_MUTEX_POSIX_H_
|
||||
|
||||
#include <shared_mutex>
|
||||
|
||||
#include "flutter/fml/synchronization/shared_mutex.h"
|
||||
|
||||
namespace fml {
|
||||
|
||||
class SharedMutexPosix : public SharedMutex {
|
||||
public:
|
||||
virtual void Lock();
|
||||
virtual void LockShared();
|
||||
virtual void Unlock();
|
||||
virtual void UnlockShared();
|
||||
|
||||
private:
|
||||
friend SharedMutex* SharedMutex::Create();
|
||||
SharedMutexPosix();
|
||||
|
||||
pthread_rwlock_t rwlock_;
|
||||
};
|
||||
|
||||
} // namespace fml
|
||||
|
||||
#endif // FLUTTER_FML_PLATFORM_POSIX_SHARED_MUTEX_POSIX_H_
|
@ -1,50 +0,0 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef FLUTTER_FML_SYNCHRONIZATION_SHARED_MUTEX_H_
|
||||
#define FLUTTER_FML_SYNCHRONIZATION_SHARED_MUTEX_H_
|
||||
|
||||
namespace fml {
|
||||
|
||||
// Interface for a reader/writer lock.
|
||||
class SharedMutex {
|
||||
public:
|
||||
static SharedMutex* Create();
|
||||
virtual ~SharedMutex() = default;
|
||||
|
||||
virtual void Lock() = 0;
|
||||
virtual void LockShared() = 0;
|
||||
virtual void Unlock() = 0;
|
||||
virtual void UnlockShared() = 0;
|
||||
};
|
||||
|
||||
// RAII wrapper that does a shared acquire of a SharedMutex.
|
||||
class SharedLock {
|
||||
public:
|
||||
explicit SharedLock(SharedMutex& shared_mutex) : shared_mutex_(shared_mutex) {
|
||||
shared_mutex_.LockShared();
|
||||
}
|
||||
|
||||
~SharedLock() { shared_mutex_.UnlockShared(); }
|
||||
|
||||
private:
|
||||
SharedMutex& shared_mutex_;
|
||||
};
|
||||
|
||||
// RAII wrapper that does an exclusive acquire of a SharedMutex.
|
||||
class UniqueLock {
|
||||
public:
|
||||
explicit UniqueLock(SharedMutex& shared_mutex) : shared_mutex_(shared_mutex) {
|
||||
shared_mutex_.Lock();
|
||||
}
|
||||
|
||||
~UniqueLock() { shared_mutex_.Unlock(); }
|
||||
|
||||
private:
|
||||
SharedMutex& shared_mutex_;
|
||||
};
|
||||
|
||||
} // namespace fml
|
||||
|
||||
#endif // FLUTTER_FML_SYNCHRONIZATION_SHARED_MUTEX_H_
|
@ -1,29 +0,0 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "flutter/fml/synchronization/shared_mutex_std.h"
|
||||
|
||||
namespace fml {
|
||||
|
||||
SharedMutex* SharedMutex::Create() {
|
||||
return new SharedMutexStd();
|
||||
}
|
||||
|
||||
void SharedMutexStd::Lock() {
|
||||
mutex_.lock();
|
||||
}
|
||||
|
||||
void SharedMutexStd::LockShared() {
|
||||
mutex_.lock_shared();
|
||||
}
|
||||
|
||||
void SharedMutexStd::Unlock() {
|
||||
mutex_.unlock();
|
||||
}
|
||||
|
||||
void SharedMutexStd::UnlockShared() {
|
||||
mutex_.unlock_shared();
|
||||
}
|
||||
|
||||
} // namespace fml
|
@ -1,30 +0,0 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef FLUTTER_FML_SYNCHRONIZATION_SHARED_MUTEX_STD_H_
|
||||
#define FLUTTER_FML_SYNCHRONIZATION_SHARED_MUTEX_STD_H_
|
||||
|
||||
#include "flutter/fml/synchronization/shared_mutex.h"
|
||||
|
||||
#include <shared_mutex>
|
||||
|
||||
namespace fml {
|
||||
|
||||
class SharedMutexStd : public SharedMutex {
|
||||
public:
|
||||
virtual void Lock();
|
||||
virtual void LockShared();
|
||||
virtual void Unlock();
|
||||
virtual void UnlockShared();
|
||||
|
||||
private:
|
||||
friend SharedMutex* SharedMutex::Create();
|
||||
SharedMutexStd() = default;
|
||||
|
||||
std::shared_timed_mutex mutex_;
|
||||
};
|
||||
|
||||
} // namespace fml
|
||||
|
||||
#endif // FLUTTER_FML_SYNCHRONIZATION_SHARED_MUTEX_STD_H_
|
@ -20,12 +20,10 @@ SyncSwitch::Handlers& SyncSwitch::Handlers::SetIfFalse(
|
||||
return *this;
|
||||
}
|
||||
|
||||
SyncSwitch::SyncSwitch(bool value)
|
||||
: mutex_(std::unique_ptr<fml::SharedMutex>(fml::SharedMutex::Create())),
|
||||
value_(value) {}
|
||||
SyncSwitch::SyncSwitch(bool value) : value_(value) {}
|
||||
|
||||
void SyncSwitch::Execute(const SyncSwitch::Handlers& handlers) const {
|
||||
fml::SharedLock lock(*mutex_);
|
||||
std::shared_lock lock(mutex_);
|
||||
if (value_) {
|
||||
handlers.true_handler();
|
||||
} else {
|
||||
@ -35,7 +33,7 @@ void SyncSwitch::Execute(const SyncSwitch::Handlers& handlers) const {
|
||||
|
||||
void SyncSwitch::SetSwitch(bool value) {
|
||||
{
|
||||
fml::UniqueLock lock(*mutex_);
|
||||
std::unique_lock lock(mutex_);
|
||||
value_ = value;
|
||||
}
|
||||
for (Observer* observer : observers_) {
|
||||
@ -44,7 +42,7 @@ void SyncSwitch::SetSwitch(bool value) {
|
||||
}
|
||||
|
||||
void SyncSwitch::AddObserver(Observer* observer) const {
|
||||
fml::UniqueLock lock(*mutex_);
|
||||
std::unique_lock lock(mutex_);
|
||||
if (std::find(observers_.begin(), observers_.end(), observer) ==
|
||||
observers_.end()) {
|
||||
observers_.push_back(observer);
|
||||
@ -52,7 +50,7 @@ void SyncSwitch::AddObserver(Observer* observer) const {
|
||||
}
|
||||
|
||||
void SyncSwitch::RemoveObserver(Observer* observer) const {
|
||||
fml::UniqueLock lock(*mutex_);
|
||||
std::unique_lock lock(mutex_);
|
||||
observers_.erase(std::remove(observers_.begin(), observers_.end(), observer),
|
||||
observers_.end());
|
||||
}
|
||||
|
@ -7,10 +7,10 @@
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <shared_mutex>
|
||||
#include <vector>
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "flutter/fml/synchronization/shared_mutex.h"
|
||||
|
||||
namespace fml {
|
||||
|
||||
@ -70,7 +70,7 @@ class SyncSwitch {
|
||||
void RemoveObserver(Observer* observer) const;
|
||||
|
||||
private:
|
||||
mutable std::unique_ptr<fml::SharedMutex> mutex_;
|
||||
mutable std::shared_mutex mutex_;
|
||||
mutable std::vector<Observer*> observers_;
|
||||
bool value_;
|
||||
|
||||
|
@ -10,9 +10,9 @@
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <shared_mutex>
|
||||
#include <thread>
|
||||
|
||||
#include "flutter/fml/synchronization/shared_mutex.h"
|
||||
#include "impeller/base/thread_safety.h"
|
||||
|
||||
namespace impeller {
|
||||
@ -45,21 +45,20 @@ class IPLR_CAPABILITY("mutex") Mutex {
|
||||
|
||||
class IPLR_CAPABILITY("mutex") RWMutex {
|
||||
public:
|
||||
RWMutex()
|
||||
: mutex_(std::unique_ptr<fml::SharedMutex>(fml::SharedMutex::Create())) {}
|
||||
RWMutex() = default;
|
||||
|
||||
~RWMutex() = default;
|
||||
|
||||
void LockWriter() IPLR_ACQUIRE() { mutex_->Lock(); }
|
||||
void LockWriter() IPLR_ACQUIRE() { mutex_.lock(); }
|
||||
|
||||
void UnlockWriter() IPLR_RELEASE() { mutex_->Unlock(); }
|
||||
void UnlockWriter() IPLR_RELEASE() { mutex_.unlock(); }
|
||||
|
||||
void LockReader() IPLR_ACQUIRE_SHARED() { mutex_->LockShared(); }
|
||||
void LockReader() IPLR_ACQUIRE_SHARED() { mutex_.lock_shared(); }
|
||||
|
||||
void UnlockReader() IPLR_RELEASE_SHARED() { mutex_->UnlockShared(); }
|
||||
void UnlockReader() IPLR_RELEASE_SHARED() { mutex_.unlock_shared(); }
|
||||
|
||||
private:
|
||||
std::unique_ptr<fml::SharedMutex> mutex_;
|
||||
std::shared_mutex mutex_;
|
||||
|
||||
RWMutex(const RWMutex&) = delete;
|
||||
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include <atomic>
|
||||
|
||||
#include "flutter/fml/logging.h"
|
||||
#include "flutter/fml/synchronization/shared_mutex.h"
|
||||
#include "flutter/fml/trace_event.h"
|
||||
#include "flutter/lib/ui/ui_dart_state.h"
|
||||
#include "flutter/lib/ui/window/platform_configuration.h"
|
||||
|
@ -59,8 +59,7 @@ ServiceProtocol::ServiceProtocol()
|
||||
kGetSkSLsExtensionName,
|
||||
kEstimateRasterCacheMemoryExtensionName,
|
||||
kReloadAssetFonts,
|
||||
}),
|
||||
handlers_mutex_(fml::SharedMutex::Create()) {}
|
||||
}) {}
|
||||
|
||||
ServiceProtocol::~ServiceProtocol() {
|
||||
ToggleHooks(false);
|
||||
@ -68,19 +67,19 @@ ServiceProtocol::~ServiceProtocol() {
|
||||
|
||||
void ServiceProtocol::AddHandler(Handler* handler,
|
||||
const Handler::Description& description) {
|
||||
fml::UniqueLock lock(*handlers_mutex_);
|
||||
std::unique_lock lock(handlers_mutex_);
|
||||
handlers_.emplace(handler, description);
|
||||
}
|
||||
|
||||
void ServiceProtocol::RemoveHandler(Handler* handler) {
|
||||
fml::UniqueLock lock(*handlers_mutex_);
|
||||
std::unique_lock lock(handlers_mutex_);
|
||||
handlers_.erase(handler);
|
||||
}
|
||||
|
||||
void ServiceProtocol::SetHandlerDescription(
|
||||
Handler* handler,
|
||||
const Handler::Description& description) {
|
||||
fml::SharedLock lock(*handlers_mutex_);
|
||||
std::shared_lock lock(handlers_mutex_);
|
||||
auto it = handlers_.find(handler);
|
||||
if (it != handlers_.end()) {
|
||||
it->second.Store(description);
|
||||
@ -191,7 +190,7 @@ bool ServiceProtocol::HandleMessage(std::string_view method,
|
||||
return HandleListViewsMethod(response);
|
||||
}
|
||||
|
||||
fml::SharedLock lock(*handlers_mutex_);
|
||||
std::shared_lock lock(handlers_mutex_);
|
||||
|
||||
if (handlers_.empty()) {
|
||||
WriteServerErrorResponse(response,
|
||||
@ -262,7 +261,7 @@ void ServiceProtocol::Handler::Description::Write(
|
||||
|
||||
bool ServiceProtocol::HandleListViewsMethod(
|
||||
rapidjson::Document* response) const {
|
||||
fml::SharedLock lock(*handlers_mutex_);
|
||||
std::shared_lock lock(handlers_mutex_);
|
||||
std::vector<std::pair<intptr_t, Handler::Description>> descriptions;
|
||||
descriptions.reserve(handlers_.size());
|
||||
for (const auto& handler : handlers_) {
|
||||
|
@ -7,12 +7,12 @@
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <shared_mutex>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "flutter/fml/synchronization/atomic_object.h"
|
||||
#include "flutter/fml/synchronization/shared_mutex.h"
|
||||
#include "flutter/fml/task_runner.h"
|
||||
#include "rapidjson/document.h"
|
||||
|
||||
@ -75,7 +75,7 @@ class ServiceProtocol {
|
||||
|
||||
private:
|
||||
const std::set<std::string_view> endpoints_;
|
||||
std::unique_ptr<fml::SharedMutex> handlers_mutex_;
|
||||
mutable std::shared_mutex handlers_mutex_;
|
||||
std::map<Handler*, fml::AtomicObject<Handler::Description>> handlers_;
|
||||
|
||||
[[nodiscard]] static bool HandleMessage(const char* method,
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <dwmapi.h>
|
||||
|
||||
#include <filesystem>
|
||||
#include <shared_mutex>
|
||||
#include <sstream>
|
||||
|
||||
#include "flutter/fml/logging.h"
|
||||
@ -150,7 +151,6 @@ FlutterWindowsEngine::FlutterWindowsEngine(
|
||||
: project_(std::make_unique<FlutterProjectBundle>(project)),
|
||||
windows_proc_table_(std::move(windows_proc_table)),
|
||||
aot_data_(nullptr, nullptr),
|
||||
views_mutex_(fml::SharedMutex::Create()),
|
||||
lifecycle_manager_(std::make_unique<WindowsLifecycleManager>(this)) {
|
||||
if (windows_proc_table_ == nullptr) {
|
||||
windows_proc_table_ = std::make_shared<WindowsProcTable>();
|
||||
@ -505,7 +505,7 @@ std::unique_ptr<FlutterWindowsView> FlutterWindowsEngine::CreateView(
|
||||
{
|
||||
// Add the view to the embedder. This must happen before the engine
|
||||
// is notified the view exists and starts presenting to it.
|
||||
fml::UniqueLock write_lock{*views_mutex_};
|
||||
std::unique_lock write_lock(views_mutex_);
|
||||
FML_DCHECK(views_.find(view_id) == views_.end());
|
||||
views_[view_id] = view.get();
|
||||
}
|
||||
@ -554,7 +554,7 @@ std::unique_ptr<FlutterWindowsView> FlutterWindowsEngine::CreateView(
|
||||
// engine's state. This is unexpected and indicates a bug in the Windows
|
||||
// embedder.
|
||||
FML_LOG(ERROR) << "FlutterEngineAddView failed to add view";
|
||||
fml::UniqueLock write_lock{*views_mutex_};
|
||||
std::unique_lock write_lock(views_mutex_);
|
||||
views_.erase(view_id);
|
||||
return nullptr;
|
||||
}
|
||||
@ -618,7 +618,7 @@ void FlutterWindowsEngine::RemoveView(FlutterViewId view_id) {
|
||||
{
|
||||
// The engine no longer presents to the view. Remove the view from the
|
||||
// embedder.
|
||||
fml::UniqueLock write_lock{*views_mutex_};
|
||||
std::unique_lock write_lock(views_mutex_);
|
||||
|
||||
FML_DCHECK(views_.find(view_id) != views_.end());
|
||||
views_.erase(view_id);
|
||||
@ -654,7 +654,7 @@ std::chrono::nanoseconds FlutterWindowsEngine::FrameInterval() {
|
||||
}
|
||||
|
||||
FlutterWindowsView* FlutterWindowsEngine::view(FlutterViewId view_id) const {
|
||||
fml::SharedLock read_lock{*views_mutex_};
|
||||
std::shared_lock read_lock(views_mutex_);
|
||||
|
||||
auto iterator = views_.find(view_id);
|
||||
if (iterator == views_.end()) {
|
||||
@ -884,7 +884,7 @@ bool FlutterWindowsEngine::DispatchSemanticsAction(
|
||||
|
||||
void FlutterWindowsEngine::UpdateSemanticsEnabled(bool enabled) {
|
||||
if (engine_ && semantics_enabled_ != enabled) {
|
||||
fml::SharedLock read_lock{*views_mutex_};
|
||||
std::shared_lock read_lock(views_mutex_);
|
||||
|
||||
semantics_enabled_ = enabled;
|
||||
embedder_api_.UpdateSemanticsEnabled(engine_, enabled);
|
||||
@ -951,7 +951,7 @@ void FlutterWindowsEngine::OnQuit(std::optional<HWND> hwnd,
|
||||
}
|
||||
|
||||
void FlutterWindowsEngine::OnDwmCompositionChanged() {
|
||||
fml::SharedLock read_lock{*views_mutex_};
|
||||
std::shared_lock read_lock(views_mutex_);
|
||||
|
||||
for (auto iterator = views_.begin(); iterator != views_.end(); iterator++) {
|
||||
iterator->second->OnDwmCompositionChanged();
|
||||
@ -987,7 +987,7 @@ bool FlutterWindowsEngine::Present(const FlutterPresentViewInfo* info) {
|
||||
// This runs on the raster thread. Lock the views map for the entirety of the
|
||||
// present operation to block the platform thread from destroying the
|
||||
// view during the present.
|
||||
fml::SharedLock read_lock{*views_mutex_};
|
||||
std::shared_lock read_lock(views_mutex_);
|
||||
|
||||
auto iterator = views_.find(info->view_id);
|
||||
if (iterator == views_.end()) {
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <shared_mutex>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <unordered_map>
|
||||
@ -16,7 +17,6 @@
|
||||
|
||||
#include "flutter/fml/closure.h"
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "flutter/fml/synchronization/shared_mutex.h"
|
||||
#include "flutter/shell/platform/common/accessibility_bridge.h"
|
||||
#include "flutter/shell/platform/common/app_lifecycle_state.h"
|
||||
#include "flutter/shell/platform/common/client_wrapper/binary_messenger_impl.h"
|
||||
@ -384,7 +384,7 @@ class FlutterWindowsEngine {
|
||||
// The platform thread acquires a shared lock to access the view.
|
||||
// The platform thread acquires an exclusive lock before adding
|
||||
// a view to the engine or after removing a view from the engine.
|
||||
std::unique_ptr<fml::SharedMutex> views_mutex_;
|
||||
mutable std::shared_mutex views_mutex_;
|
||||
|
||||
// Task runner for tasks posted from the engine.
|
||||
std::unique_ptr<TaskRunner> task_runner_;
|
||||
|
Loading…
x
Reference in New Issue
Block a user