ticker: add ticker_trytick

For the fastpath, we want to tick, but undo the tick and jump to the
slowpath if ticker would fire.
This commit is contained in:
Dave Watson 2018-10-16 10:23:08 -07:00
parent ac34afb403
commit 0ec656eb71

View File

@ -75,4 +75,17 @@ ticker_tick(ticker_t *ticker) {
return ticker_ticks(ticker, 1); return ticker_ticks(ticker, 1);
} }
/*
* Try to tick. If ticker would fire, return true, but rely on
* slowpath to reset ticker.
*/
static inline bool
ticker_trytick(ticker_t *ticker) {
--ticker->tick;
if (unlikely(ticker->tick < 0)) {
return true;
}
return false;
}
#endif /* JEMALLOC_INTERNAL_TICKER_H */ #endif /* JEMALLOC_INTERNAL_TICKER_H */