Skip to content

Commit

Permalink
migrate from nested-name ReadHolder in mcrouter
Browse files Browse the repository at this point in the history
Summary: Migrate from nested-name `{mutex}::ReadHolder` to `std::shared_lock`.

Reviewed By: dmm-fb

Differential Revision: D53276105

fbshipit-source-id: 3b5e85482fa5bdf0faa97f0ab48379711761a22a
  • Loading branch information
yfeldblum authored and facebook-github-bot committed Feb 2, 2024
1 parent 8c500cb commit d07d8a7
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion mcrouter/AsyncWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ bool AsyncWriter::start(folly::StringPiece threadName) {
}

bool AsyncWriter::run(std::function<void()> f) {
folly::SharedMutex::ReadHolder lock(runLock_);
std::shared_lock lock(runLock_);
if (stopped_) {
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions mcrouter/CallbackPool-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ CallbackPool<Args...>::CallbackPool() : data_(std::make_shared<Data>()) {}

template <typename... Args>
void CallbackPool<Args...>::notify(Args... args) {
folly::SharedMutex::ReadHolder lck(data_->callbackLock);
std::shared_lock lck(data_->callbackLock);
for (auto& it : data_->callbacks) {
try {
it->func_(args...);
Expand All @@ -73,7 +73,7 @@ typename CallbackPool<Args...>::CallbackHandle CallbackPool<Args...>::subscribe(

template <typename... Args>
bool CallbackPool<Args...>::empty() {
folly::SharedMutex::ReadHolder lck(data_->callbackLock);
std::shared_lock lck(data_->callbackLock);
return data_->callbacks.empty();
}

Expand Down
4 changes: 2 additions & 2 deletions mcrouter/Observable-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ typename Observable<Data>::CallbackHandle Observable<Data>::subscribe(
template <class Data>
typename Observable<Data>::CallbackHandle Observable<Data>::subscribeAndCall(
OnUpdateOldNew callback) {
folly::SharedMutex::ReadHolder lck(dataLock_);
std::shared_lock lck(dataLock_);
try {
callback(Data(), data_);
} catch (const std::exception& e) {
Expand All @@ -45,7 +45,7 @@ typename Observable<Data>::CallbackHandle Observable<Data>::subscribeAndCall(

template <class Data>
Data Observable<Data>::get() {
folly::SharedMutex::ReadHolder lck(dataLock_);
std::shared_lock lck(dataLock_);
return data_;
}

Expand Down
2 changes: 1 addition & 1 deletion mcrouter/Proxy-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ Proxy<RouterInfo>* Proxy<RouterInfo>::createProxy(
template <class RouterInfo>
std::shared_ptr<ProxyConfig<RouterInfo>> Proxy<RouterInfo>::getConfigUnsafe()
const {
folly::SharedMutex::ReadHolder lg(configLock_);
std::shared_lock lg(configLock_);
return config_;
}

Expand Down
2 changes: 1 addition & 1 deletion mcrouter/lib/network/AsyncMcServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ void AsyncMcServer::setTicketKeySeeds(wangle::TLSTicketKeySeeds seeds) {
}

wangle::TLSTicketKeySeeds AsyncMcServer::getTicketKeySeeds() const {
folly::SharedMutex::ReadHolder readGuard(tlsTicketKeySeedsLock_);
std::shared_lock readGuard(tlsTicketKeySeedsLock_);
return tlsTicketKeySeeds_;
}

Expand Down
6 changes: 3 additions & 3 deletions mcrouter/lib/network/McSSLUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ bool McSSLUtil::verifySSL(
X509_STORE_CTX* ctx) noexcept {
// It should be fine to hold onto the read holder since writes to this
// will typically happen at app startup.
folly::SharedMutex::ReadHolder rh(getMutex());
std::shared_lock rh(getMutex());
auto& func = getAppFuncRef();
if (!func) {
return verifySSLWithDefaultBehavior(sock, preverifyOk, ctx);
Expand Down Expand Up @@ -191,7 +191,7 @@ folly::AsyncTransportWrapper::UniquePtr McSSLUtil::moveToPlaintext(

folly::AsyncTransportWrapper::UniquePtr McSSLUtil::moveToKtls(
folly::AsyncTransportWrapper& sock) noexcept {
folly::SharedMutex::ReadHolder rh(getMutex());
std::shared_lock rh(getMutex());
auto& func = getKtlsFuncRef();
if (func) {
return func(sock);
Expand All @@ -201,7 +201,7 @@ folly::AsyncTransportWrapper::UniquePtr McSSLUtil::moveToKtls(

McSSLUtil::CertPair McSSLUtil::dropCertificateX509Payload(
folly::AsyncSSLSocket& sock) noexcept {
folly::SharedMutex::ReadHolder rh(getMutex());
std::shared_lock rh(getMutex());
auto& func = getDropCertificateX509PayloadFuncRef();
if (func) {
return func(sock);
Expand Down

0 comments on commit d07d8a7

Please sign in to comment.