From 31d546bd3405bb0bf8ba6419e8142979ec0918d9 Mon Sep 17 00:00:00 2001 From: Yedidya Feldblum Date: Tue, 19 Dec 2023 11:01:13 -0800 Subject: [PATCH] migrate from nested-name WriteHolder in mcrouter/ Summary: Migrate from nested-name `{mutex}::WriteHolder` to `std::unique_lock`. Reviewed By: dmm-fb Differential Revision: D52231368 fbshipit-source-id: 019da7f1d5ea17a74c663c0dff03ee602b8b38c3 --- mcrouter/AsyncWriter.cpp | 8 ++++---- mcrouter/CallbackPool-inl.h | 4 ++-- mcrouter/Observable-inl.h | 2 +- mcrouter/Proxy-inl.h | 2 +- mcrouter/lib/network/AsyncMcServer.cpp | 2 +- mcrouter/lib/network/McSSLUtil.cpp | 8 ++++---- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/mcrouter/AsyncWriter.cpp b/mcrouter/AsyncWriter.cpp index b35c73f3c..38b86e4aa 100644 --- a/mcrouter/AsyncWriter.cpp +++ b/mcrouter/AsyncWriter.cpp @@ -35,7 +35,7 @@ AsyncWriter::~AsyncWriter() { void AsyncWriter::stop() noexcept { { - folly::SharedMutex::WriteHolder lock(runLock_); + std::unique_lock lock(runLock_); if (stopped_) { return; } @@ -53,7 +53,7 @@ void AsyncWriter::stop() noexcept { } bool AsyncWriter::start(folly::StringPiece threadName) { - folly::SharedMutex::WriteHolder lock(runLock_); + std::unique_lock lock(runLock_); if (thread_.joinable() || stopped_) { return false; } @@ -110,7 +110,7 @@ bool AsyncWriter::run(std::function f) { } void AsyncWriter::increaseMaxQueueSize(size_t add) { - folly::SharedMutex::WriteHolder lock(runLock_); + std::unique_lock lock(runLock_); // Don't touch maxQueueSize_ if it's already unlimited (zero). if (maxQueueSize_ != 0) { maxQueueSize_ += add; @@ -118,7 +118,7 @@ void AsyncWriter::increaseMaxQueueSize(size_t add) { } void AsyncWriter::makeQueueSizeUnlimited() { - folly::SharedMutex::WriteHolder lock(runLock_); + std::unique_lock lock(runLock_); maxQueueSize_ = 0; } diff --git a/mcrouter/CallbackPool-inl.h b/mcrouter/CallbackPool-inl.h index 4f733eeb9..ec2951861 100644 --- a/mcrouter/CallbackPool-inl.h +++ b/mcrouter/CallbackPool-inl.h @@ -21,7 +21,7 @@ struct CallbackPool::CallbackHandleImpl { CallbackHandleImpl(const CallbackHandleImpl&) = delete; CallbackHandleImpl& operator=(const CallbackHandleImpl&) = delete; ~CallbackHandleImpl() { - folly::SharedMutex::WriteHolder lck(data_->callbackLock); + std::unique_lock lck(data_->callbackLock); data_->callbacks.erase(this); } @@ -33,7 +33,7 @@ struct CallbackPool::CallbackHandleImpl { CallbackHandleImpl(std::shared_ptr data, OnUpdateFunc func) : data_(std::move(data)), func_(std::move(func)) { - folly::SharedMutex::WriteHolder lck(data_->callbackLock); + std::unique_lock lck(data_->callbackLock); data_->callbacks.insert(this); } }; diff --git a/mcrouter/Observable-inl.h b/mcrouter/Observable-inl.h index 2dd8ed696..3b24da1c8 100644 --- a/mcrouter/Observable-inl.h +++ b/mcrouter/Observable-inl.h @@ -51,7 +51,7 @@ Data Observable::get() { template void Observable::set(Data data) { - folly::SharedMutex::WriteHolder lck(dataLock_); + std::unique_lock lck(dataLock_); auto old = std::move(data_); data_ = std::move(data); // no copy here, because old and data are passed by const reference diff --git a/mcrouter/Proxy-inl.h b/mcrouter/Proxy-inl.h index a32225144..f417af4a0 100644 --- a/mcrouter/Proxy-inl.h +++ b/mcrouter/Proxy-inl.h @@ -278,7 +278,7 @@ Proxy::getConfigLocked() const { template std::shared_ptr> Proxy::swapConfig( std::shared_ptr> newConfig) { - folly::SharedMutex::WriteHolder lg(configLock_); + std::unique_lock lg(configLock_); auto old = std::move(config_); config_ = std::move(newConfig); return old; diff --git a/mcrouter/lib/network/AsyncMcServer.cpp b/mcrouter/lib/network/AsyncMcServer.cpp index ea31c28ec..14598ad63 100644 --- a/mcrouter/lib/network/AsyncMcServer.cpp +++ b/mcrouter/lib/network/AsyncMcServer.cpp @@ -959,7 +959,7 @@ void AsyncMcServer::join() { } void AsyncMcServer::setTicketKeySeeds(wangle::TLSTicketKeySeeds seeds) { - folly::SharedMutex::WriteHolder writeGuard(tlsTicketKeySeedsLock_); + std::unique_lock writeGuard(tlsTicketKeySeedsLock_); tlsTicketKeySeeds_ = std::move(seeds); } diff --git a/mcrouter/lib/network/McSSLUtil.cpp b/mcrouter/lib/network/McSSLUtil.cpp index 2df19c824..98c59cd3c 100644 --- a/mcrouter/lib/network/McSSLUtil.cpp +++ b/mcrouter/lib/network/McSSLUtil.cpp @@ -88,24 +88,24 @@ bool McSSLUtil::verifySSLWithDefaultBehavior( void McSSLUtil::setApplicationKtlsFunctions( SSLToKtlsFunction func, KtlsStatsFunction statsFunc) { - folly::SharedMutex::WriteHolder wh(getMutex()); + std::unique_lock wh(getMutex()); getKtlsFuncRef() = std::move(func); getKtlsStatsFuncRef() = std::move(statsFunc); } void McSSLUtil::setApplicationSSLVerifier(SSLVerifyFunction func) { - folly::SharedMutex::WriteHolder wh(getMutex()); + std::unique_lock wh(getMutex()); getAppFuncRef() = std::move(func); } void McSSLUtil::setClientIdentityHook(apache::thrift::ClientIdentityHook func) { - folly::SharedMutex::WriteHolder wh(getMutex()); + std::unique_lock wh(getMutex()); getClientIdentityHookFuncRef() = std::move(func); } void McSSLUtil::setDropCertificateX509PayloadFunction( DropCertificateX509PayloadFunction func) { - folly::SharedMutex::WriteHolder wh(getMutex()); + std::unique_lock wh(getMutex()); getDropCertificateX509PayloadFuncRef() = std::move(func); }