From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Vladimir Davydov Subject: [PATCH 04/18] vinyl: implement vy_quota_wait using vy_quota_try_use Date: Thu, 16 Aug 2018 19:11:58 +0300 Message-Id: <9fc62169f558d740ce990239f38d3a5c67aa7f2b.1534432819.git.vdavydov.dev@gmail.com> In-Reply-To: References: In-Reply-To: References: To: kostja@tarantool.org Cc: tarantool-patches@freelists.org List-ID: 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