Migrate counter to use locked int

This commit is contained in:
Yinan Zhang
2020-04-14 15:08:00 -07:00
parent b543c20a94
commit fc052ff728
4 changed files with 54 additions and 52 deletions

View File

@@ -6,18 +6,12 @@
bool
counter_accum_init(counter_accum_t *counter, uint64_t interval) {
#ifndef JEMALLOC_ATOMIC_U64
if (malloc_mutex_init(&counter->mtx, "counter_accum",
if (LOCKEDINT_MTX_INIT(counter->mtx, "counter_accum",
WITNESS_RANK_COUNTER_ACCUM, malloc_mutex_rank_exclusive)) {
return true;
}
counter->accumbytes = 0;
#else
atomic_store_u64(&counter->accumbytes, 0,
ATOMIC_RELAXED);
#endif
locked_init_u64_unsynchronized(&counter->accumbytes, 0);
counter->interval = interval;
return false;
}