//===- llvm/Support/ExponentialBackoff.h ------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file defines a helper class for implementing exponential backoff. // //===----------------------------------------------------------------------===// #ifndef LLVM_EXPONENTIALBACKOFF_H #define LLVM_EXPONENTIALBACKOFF_H #include "llvm/ADT/STLExtras.h" #include "llvm/Support/Error.h" #include <chrono> #include <random> namespace llvm { /// A class to help implement exponential backoff. /// /// Example usage: /// \code /// ExponentialBackoff Backoff(10s); /// do { /// if (tryToDoSomething()) /// return ItWorked; /// } while (Backoff.waitForNextAttempt()); /// return Timeout; /// \endcode class ExponentialBackoff { … }; } // end namespace llvm #endif // LLVM_EXPONENTIALBACKOFF_H