aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/backoff/backoff.h
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2017-11-08 09:42:32 -0800
committerGravatar Craig Tiller <ctiller@google.com>2017-11-08 09:42:32 -0800
commit660d4aa2d281dbfbc6c3a3e3349b3e4b6a444285 (patch)
tree592cecc1d6670bb12b9af81c19cd3cb98cc0eeef /src/core/lib/backoff/backoff.h
parent48d26966646e910f7dd63d428ef831178ca9315e (diff)
parentd9da7387b8057f3bd99a417a5ee905377bce9296 (diff)
Merge github.com:grpc/grpc into tfix2
Diffstat (limited to 'src/core/lib/backoff/backoff.h')
-rw-r--r--src/core/lib/backoff/backoff.h57
1 files changed, 37 insertions, 20 deletions
diff --git a/src/core/lib/backoff/backoff.h b/src/core/lib/backoff/backoff.h
index 80e49ea52a..1067281403 100644
--- a/src/core/lib/backoff/backoff.h
+++ b/src/core/lib/backoff/backoff.h
@@ -27,37 +27,54 @@ extern "C" {
typedef struct {
/// const: how long to wait after the first failure before retrying
- grpc_millis initial_connect_timeout;
+ grpc_millis initial_backoff;
+
/// const: factor with which to multiply backoff after a failed retry
double multiplier;
+
/// const: amount to randomize backoffs
double jitter;
- /// const: minimum time between retries in milliseconds
- grpc_millis min_timeout_millis;
- /// const: maximum time between retries in milliseconds
- grpc_millis max_timeout_millis;
+
+ /// const: minimum time between retries
+ grpc_millis min_connect_timeout;
+
+ /// const: maximum time between retries
+ grpc_millis max_backoff;
+
+ /// current delay before retries
+ grpc_millis current_backoff;
/// random number generator
uint32_t rng_state;
-
- /// current retry timeout in milliseconds
- grpc_millis current_timeout_millis;
} grpc_backoff;
+typedef struct {
+ /// Deadline to be used for the current attempt.
+ grpc_millis current_deadline;
+
+ /// Deadline to be used for the next attempt, following the backoff strategy.
+ grpc_millis next_attempt_start_time;
+} grpc_backoff_result;
+
/// Initialize backoff machinery - does not need to be destroyed
-void grpc_backoff_init(grpc_backoff *backoff,
- grpc_millis initial_connect_timeout, double multiplier,
- double jitter, grpc_millis min_timeout_millis,
- grpc_millis max_timeout_millis);
-
-/// Begin retry loop: returns a timespec for the NEXT retry
-grpc_millis grpc_backoff_begin(grpc_exec_ctx *exec_ctx, grpc_backoff *backoff);
-/// Step a retry loop: returns a timespec for the NEXT retry
-grpc_millis grpc_backoff_step(grpc_exec_ctx *exec_ctx, grpc_backoff *backoff);
+void grpc_backoff_init(grpc_backoff* backoff, grpc_millis initial_backoff,
+ double multiplier, double jitter,
+ grpc_millis min_connect_timeout,
+ grpc_millis max_backoff);
+
+/// Begin retry loop: returns the deadlines to be used for the current attempt
+/// and the subsequent retry, if any.
+grpc_backoff_result grpc_backoff_begin(grpc_exec_ctx* exec_ctx,
+ grpc_backoff* backoff);
+
+/// Step a retry loop: returns the deadlines to be used for the current attempt
+/// and the subsequent retry, if any.
+grpc_backoff_result grpc_backoff_step(grpc_exec_ctx* exec_ctx,
+ grpc_backoff* backoff);
+
/// Reset the backoff, so the next grpc_backoff_step will be a
-/// grpc_backoff_begin
-/// instead
-void grpc_backoff_reset(grpc_backoff *backoff);
+/// grpc_backoff_begin.
+void grpc_backoff_reset(grpc_backoff* backoff);
#ifdef __cplusplus
}