aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvvshlyaga <vvshlyaga@yandex-team.com>2025-04-25 21:24:17 +0300
committervvshlyaga <vvshlyaga@yandex-team.com>2025-04-25 21:40:06 +0300
commit452d892ccb5ffd6b496939e339cf200e558ce9bc (patch)
treed83c8bdd51f0b05fb5219060ed177ba87eccdb9b
parentf67993e3f134e026f43e29a6c24d88a89a964ae5 (diff)
downloadydb-452d892ccb5ffd6b496939e339cf200e558ce9bc.tar.gz
YT-23817: implement try acquire in TCombinedThroughputThrottler
commit_hash:7e61a1191c39017d06254e045d3f58bbbbdadc01
-rw-r--r--yt/yt/core/concurrency/throughput_throttler.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/yt/yt/core/concurrency/throughput_throttler.cpp b/yt/yt/core/concurrency/throughput_throttler.cpp
index c88a7a2ddd2..daafe952a33 100644
--- a/yt/yt/core/concurrency/throughput_throttler.cpp
+++ b/yt/yt/core/concurrency/throughput_throttler.cpp
@@ -725,11 +725,26 @@ public:
}));
}
- bool TryAcquire(i64 /*amount*/) override
+ bool TryAcquire(i64 amount) override
{
- YT_ABORT();
+ size_t i = 0;
+ for (; i < Throttlers_.size(); ++i) {
+ if (!Throttlers_[i]->TryAcquire(amount)) {
+ break;
+ }
+ }
+
+ if (i != Throttlers_.size()) {
+ for (size_t j = 0; j < i; ++j) {
+ Throttlers_[j]->Release(amount);
+ }
+ return false;
+ }
+
+ return true;
}
+ // TODO: implement TryAcquireAvailable the same way as TryAcquire.
i64 TryAcquireAvailable(i64 /*amount*/) override
{
YT_ABORT();