Function retry

Source
pub fn retry<R, E>(f: impl Fn() -> Result<R, E>) -> R
Expand description

Rerun f until it returns Ok, only sleeps after 100 attempts, panics after 200 attempts. Mostly useful for atomic compare_exchange. I.e. do not use if f expects a value from another thread; just do retries that should succeed except for bad luck when another thread is making a change at the same time.