[PATCH 04/18] vinyl: implement vy_quota_wait using vy_quota_try_use
Vladimir Davydov
vdavydov.dev at gmail.com
Thu Aug 16 19:11:58 MSK 2018
So that there's a single place where we can wait for quota. It should
make it easier to implement quota throttling.
---
src/box/vy_quota.c | 7 -------
src/box/vy_quota.h | 7 +++++--
2 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/src/box/vy_quota.c b/src/box/vy_quota.c
index c8177c69..3ea7c80f 100644
--- a/src/box/vy_quota.c
+++ b/src/box/vy_quota.c
@@ -223,10 +223,3 @@ vy_quota_commit_use(struct vy_quota *q, size_t reserved, size_t used)
if (reserved < used)
vy_quota_force_use(q, used - reserved);
}
-
-void
-vy_quota_wait(struct vy_quota *q)
-{
- while (q->used > q->limit)
- fiber_cond_wait(&q->cond);
-}
diff --git a/src/box/vy_quota.h b/src/box/vy_quota.h
index 3a7a24e7..9bfb48f5 100644
--- a/src/box/vy_quota.h
+++ b/src/box/vy_quota.h
@@ -190,8 +190,11 @@ vy_quota_commit_use(struct vy_quota *q, size_t reserved, size_t used);
/**
* Block the caller until the quota is not exceeded.
*/
-void
-vy_quota_wait(struct vy_quota *q);
+static inline void
+vy_quota_wait(struct vy_quota *q)
+{
+ vy_quota_try_use(q, 0, TIMEOUT_INFINITY);
+}
#if defined(__cplusplus)
} /* extern "C" */
--
2.11.0
More information about the Tarantool-patches
mailing list