15 namespace exp_backoff {
25#define SPARTA_EXPBO_CONCAT_ARG2(x,y,z) x##_##y##_##z
32#define SPARTA_EXPBO_CONCAT_ARG(x,y,z) SPARTA_EXPBO_CONCAT_ARG2(x,y,z)
52#define SPARTA_EXPONENTIAL_BACKOFF(mult, action) \
53 static sparta::exp_backoff::counter_t SPARTA_EXPBO_CONCAT_ARG(_count,__LINE__,mult) = 0; \
54 static sparta::exp_backoff::counter_t SPARTA_EXPBO_CONCAT_ARG(_next,__LINE__,mult) = 1; \
55 SPARTA_EXPBO_CONCAT_ARG(_count,__LINE__,mult) ++; \
56 if(SPARTA_EXPBO_CONCAT_ARG(_count,__LINE__,mult) >= SPARTA_EXPBO_CONCAT_ARG(_next,__LINE__,mult)){ \
57 const sparta::exp_backoff::counter_t& SPARTA_EXPONENTIAL_BACKOFF_COUNT = SPARTA_EXPBO_CONCAT_ARG(_count,__LINE__,mult); \
58 (void) SPARTA_EXPONENTIAL_BACKOFF_COUNT; \
60 SPARTA_EXPBO_CONCAT_ARG(_next,__LINE__,mult) *= mult; \
uint32_t counter_t
Type use for exponential backoff counters.
Macros for handling exponential backoff.