aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbabenko <babenko@yandex-team.com>2024-05-11 22:41:33 +0300
committerbabenko <babenko@yandex-team.com>2024-05-11 22:56:07 +0300
commitda69ef6fc9bd666f063e47934abdab850ec03bad (patch)
tree67f84163a4ae4402d7670edc5b07ade1364f9ab0
parentb946c1e1f97a9aae42e87b642c74959093e2582a (diff)
downloadydb-da69ef6fc9bd666f063e47934abdab850ec03bad.tar.gz
Fix weak this bugs and unify naming
b19051a5c79fed1c2f03d5ac56f2fef8d4677e1f
-rw-r--r--yt/yt/client/chunk_client/ready_event_reader_base.cpp6
-rw-r--r--yt/yt/core/actions/bind-inl.h12
-rw-r--r--yt/yt/core/concurrency/invoker_alarm.cpp4
-rw-r--r--yt/yt/core/concurrency/periodic_executor_base-inl.h12
-rw-r--r--yt/yt/core/concurrency/throughput_throttler.cpp4
-rw-r--r--yt/yt/core/http/connection_pool.cpp7
-rw-r--r--yt/yt/core/rpc/dynamic_channel_pool.cpp14
-rw-r--r--yt/yt/core/ytree/ypath_service.cpp4
8 files changed, 29 insertions, 34 deletions
diff --git a/yt/yt/client/chunk_client/ready_event_reader_base.cpp b/yt/yt/client/chunk_client/ready_event_reader_base.cpp
index 6f7e217916..e1bf3997fd 100644
--- a/yt/yt/client/chunk_client/ready_event_reader_base.cpp
+++ b/yt/yt/client/chunk_client/ready_event_reader_base.cpp
@@ -22,9 +22,9 @@ void TReadyEventReaderBase::SetReadyEvent(TFuture<void> readyEvent)
{
// We could use TTimingGuard here but we try to not prolong
// reader lifetime for such insignificant business as timing.
- ReadyEvent_ = readyEvent.Apply(BIND([weakThis = MakeWeak(this)] {
- if (auto strongThis = weakThis.Lock()) {
- strongThis->WaitTimer_.Stop();
+ ReadyEvent_ = readyEvent.Apply(BIND([this, weakThis = MakeWeak(this)] {
+ if (auto this_ = weakThis.Lock()) {
+ WaitTimer_.Stop();
}
}));
}
diff --git a/yt/yt/core/actions/bind-inl.h b/yt/yt/core/actions/bind-inl.h
index d4c2072eb3..7bf5b529b4 100644
--- a/yt/yt/core/actions/bind-inl.h
+++ b/yt/yt/core/actions/bind-inl.h
@@ -265,12 +265,12 @@ public:
std::is_void_v<TResult>,
"Weak calls are only supported for methods with a void return type");
- auto strongThis = weakThis.Lock();
- if (!strongThis) {
+ auto this_ = weakThis.Lock();
+ if (!this_) {
return;
}
- (strongThis.Get()->*Method_)(std::forward<XAs>(args)...);
+ (this_.Get()->*Method_)(std::forward<XAs>(args)...);
}
template <class D, class... XAs>
@@ -411,12 +411,12 @@ public:
template <class D, class... XAs>
auto operator()(const TWeakPtr<D>& weakThis, XAs&&... args) const
{
- auto strongThis = weakThis.Lock();
- if (!strongThis) {
+ auto this_ = weakThis.Lock();
+ if (!this_) {
THROW_ERROR_EXCEPTION(NYT::EErrorCode::Canceled, "Object destroyed");
}
- return (strongThis.Get()->*Method_)(std::forward<XAs>(args)...);
+ return (this_.Get()->*Method_)(std::forward<XAs>(args)...);
}
private:
diff --git a/yt/yt/core/concurrency/invoker_alarm.cpp b/yt/yt/core/concurrency/invoker_alarm.cpp
index 026a602c58..6f0670cd88 100644
--- a/yt/yt/core/concurrency/invoker_alarm.cpp
+++ b/yt/yt/core/concurrency/invoker_alarm.cpp
@@ -26,8 +26,8 @@ void TInvokerAlarm::Arm(TClosure callback, TInstant deadline)
TDelayedExecutor::Submit(
BIND([=, this, weakThis = MakeWeak(this)] {
- auto strongThis = weakThis.Lock();
- if (!strongThis) {
+ auto this_ = weakThis.Lock();
+ if (!this_) {
return;
}
diff --git a/yt/yt/core/concurrency/periodic_executor_base-inl.h b/yt/yt/core/concurrency/periodic_executor_base-inl.h
index 6852a398e9..acc691920a 100644
--- a/yt/yt/core/concurrency/periodic_executor_base-inl.h
+++ b/yt/yt/core/concurrency/periodic_executor_base-inl.h
@@ -158,14 +158,14 @@ void TPeriodicExecutorBase<TInvocationTimePolicy>::PostCallback()
{
GuardedInvoke(
Invoker_,
- [weakThis = MakeWeak(this)] {
- if (auto strongThis = weakThis.Lock()) {
- strongThis->RunCallback();
+ [this, weakThis = MakeWeak(this)] {
+ if (auto this_ = weakThis.Lock()) {
+ RunCallback();
}
},
- [weakThis = MakeWeak(this)] {
- if (auto strongThis = weakThis.Lock()) {
- strongThis->OnCallbackCancelled();
+ [this, weakThis = MakeWeak(this)] {
+ if (auto this_ = weakThis.Lock()) {
+ OnCallbackCancelled();
}
});
}
diff --git a/yt/yt/core/concurrency/throughput_throttler.cpp b/yt/yt/core/concurrency/throughput_throttler.cpp
index c7a06ef199..aa8d7f845b 100644
--- a/yt/yt/core/concurrency/throughput_throttler.cpp
+++ b/yt/yt/core/concurrency/throughput_throttler.cpp
@@ -612,9 +612,9 @@ public:
asyncResults.push_back(throttler->Throttle(amount));
}
- return AllSucceeded(asyncResults).Apply(BIND([weakThis = MakeWeak(this), amount] (const TError& /*error*/ ) {
+ return AllSucceeded(asyncResults).Apply(BIND([this, weakThis = MakeWeak(this), amount] (const TError& /*error*/ ) {
if (auto this_ = weakThis.Lock()) {
- this_->SelfQueueSize_ -= amount;
+ SelfQueueSize_ -= amount;
}
}));
}
diff --git a/yt/yt/core/http/connection_pool.cpp b/yt/yt/core/http/connection_pool.cpp
index 3c60d3c921..a14891164c 100644
--- a/yt/yt/core/http/connection_pool.cpp
+++ b/yt/yt/core/http/connection_pool.cpp
@@ -33,12 +33,7 @@ TConnectionPool::TConnectionPool(
, ExpiredConnectionsCollector_(
New<TPeriodicExecutor>(
std::move(invoker),
- BIND([weakThis = MakeWeak(this)] {
- auto this_ = weakThis.Lock();
- if (this_) {
- this_->DropExpiredConnections();
- }
- }),
+ BIND(&TConnectionPool::DropExpiredConnections, MakeWeak(this)),
TPeriodicExecutorOptions::WithJitter(
Config_->ConnectionIdleTimeout)))
{
diff --git a/yt/yt/core/rpc/dynamic_channel_pool.cpp b/yt/yt/core/rpc/dynamic_channel_pool.cpp
index efe0fbb152..e6c858a1e3 100644
--- a/yt/yt/core/rpc/dynamic_channel_pool.cpp
+++ b/yt/yt/core/rpc/dynamic_channel_pool.cpp
@@ -101,12 +101,12 @@ public:
? session->GetFinished()
: ViablePeerRegistry_->GetPeersAvailable();
YT_LOG_DEBUG_IF(!future.IsSet(), "Channel requested, waiting on peers to become available");
- return future.Apply(BIND([this_ = MakeWeak(this), request, hedgingOptions] {
- if (auto strongThis = this_.Lock()) {
- auto channel = strongThis->PickViableChannel(request, hedgingOptions);
+ return future.Apply(BIND([this, weakThis = MakeWeak(this), request, hedgingOptions] {
+ if (auto this_ = weakThis.Lock()) {
+ auto channel = PickViableChannel(request, hedgingOptions);
if (!channel) {
// Not very likely but possible in theory.
- THROW_ERROR strongThis->MakeNoAlivePeersError();
+ THROW_ERROR MakeNoAlivePeersError();
}
return channel;
} else {
@@ -886,9 +886,9 @@ private:
Config_->AcknowledgementTimeout,
BIND(&TImpl::OnChannelFailed, MakeWeak(this), address),
BIND(&IsChannelFailureError),
- BIND([this_ = MakeWeak(this)] (TError error) {
- if (auto strongThis = this_.Lock()) {
- return strongThis->TransformChannelError(std::move(error));
+ BIND([this, weakThis = MakeWeak(this)] (TError error) {
+ if (auto this_ = weakThis.Lock()) {
+ return TransformChannelError(std::move(error));
} else {
return error;
}
diff --git a/yt/yt/core/ytree/ypath_service.cpp b/yt/yt/core/ytree/ypath_service.cpp
index 676d16824c..cc31e0b7b4 100644
--- a/yt/yt/core/ytree/ypath_service.cpp
+++ b/yt/yt/core/ytree/ypath_service.cpp
@@ -703,10 +703,10 @@ public:
, CacheKey_(std::move(cacheKey))
{
underlyingContext->GetAsyncResponseMessage()
- .Subscribe(BIND([weakThis = MakeWeak(this)] (const TErrorOr<TSharedRefArray>& responseMessageOrError) {
+ .Subscribe(BIND([this, weakThis = MakeWeak(this)] (const TErrorOr<TSharedRefArray>& responseMessageOrError) {
if (auto this_ = weakThis.Lock()) {
if (responseMessageOrError.IsOK()) {
- this_->TryAddResponseToCache(responseMessageOrError.Value());
+ TryAddResponseToCache(responseMessageOrError.Value());
}
}
}));