REQUIRE(VALID_QUOTA(quota));
quota->magic = 0;
- INSIST(atomic_load("a->used) == 0);
- INSIST(atomic_load("a->waiting) == 0);
+ INSIST(atomic_load_acquire("a->used) == 0);
+ INSIST(atomic_load_acquire("a->waiting) == 0);
INSIST(ISC_LIST_EMPTY(quota->cbs));
atomic_store_relaxed("a->max, 0);
- atomic_store_release("a->used, 0);
atomic_store_relaxed("a->soft, 0);
isc_mutex_destroy("a->cblock);
}
unsigned int
isc_quota_getused(isc_quota_t *quota) {
REQUIRE(VALID_QUOTA(quota));
- return atomic_load_relaxed("a->used);
+ return atomic_load_acquire("a->used);
}
static isc_result_t
enqueue(isc_quota_t *quota, isc_quota_cb_t *cb) {
REQUIRE(cb != NULL);
ISC_LIST_ENQUEUE(quota->cbs, cb, link);
+ /* No need for acquire; the lock protects from other writers. */
atomic_fetch_add_release("a->waiting, 1);
}
isc_quota_cb_t *cb = ISC_LIST_HEAD(quota->cbs);
INSIST(cb != NULL);
ISC_LIST_DEQUEUE(quota->cbs, cb, link);
- atomic_fetch_sub_relaxed("a->waiting, 1);
+ /* No need for acquire; the lock protects from other writers. */
+ atomic_fetch_sub_release("a->waiting, 1);
return cb;
}
if (atomic_load_acquire("a->waiting) > 0) {
isc_quota_cb_t *cb = NULL;
LOCK("a->cblock);
+ /* No need for acquire; the lock protects from other writers. */
if (atomic_load_relaxed("a->waiting) > 0) {
cb = dequeue(quota);
}
}
}
- used = atomic_fetch_sub_release("a->used, 1);
+ used = atomic_fetch_sub_acq_rel("a->used, 1);
INSIST(used > 0);
}