diff options
author | Craig Tiller <ctiller@google.com> | 2017-03-29 09:07:14 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2017-03-29 09:07:14 -0700 |
commit | d9bc2bf8252c6a29fb7fcc21be22f7ccd285e619 (patch) | |
tree | e992992b0b9995ccad398f7b7db37ff511d4efe4 /src/core/lib/iomgr | |
parent | 1a7692683fc40579180dee72bb2863a9bca827b6 (diff) | |
parent | d07275764717272c451ace7d7bd10c8d9a51ab6a (diff) |
Merge github.com:grpc/grpc into atomic-timers
Diffstat (limited to 'src/core/lib/iomgr')
-rw-r--r-- | src/core/lib/iomgr/resource_quota.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/core/lib/iomgr/resource_quota.c b/src/core/lib/iomgr/resource_quota.c index 511ffdcdf1..8dcd80d001 100644 --- a/src/core/lib/iomgr/resource_quota.c +++ b/src/core/lib/iomgr/resource_quota.c @@ -279,11 +279,17 @@ static void rq_step_sched(grpc_exec_ctx *exec_ctx, /* update the atomically available resource estimate - use no barriers since timeliness of delivery really doesn't matter much */ static void rq_update_estimate(grpc_resource_quota *resource_quota) { + gpr_atm memory_usage_estimation = MEMORY_USAGE_ESTIMATION_MAX; + if (resource_quota->size != 0) { + memory_usage_estimation = + GPR_CLAMP((gpr_atm)((1.0 - + ((double)resource_quota->free_pool) / + ((double)resource_quota->size)) * + MEMORY_USAGE_ESTIMATION_MAX), + 0, MEMORY_USAGE_ESTIMATION_MAX); + } gpr_atm_no_barrier_store(&resource_quota->memory_usage_estimation, - (gpr_atm)((1.0 - - ((double)resource_quota->free_pool) / - ((double)resource_quota->size)) * - MEMORY_USAGE_ESTIMATION_MAX)); + memory_usage_estimation); } /* returns true if all allocations are completed */ |