diff options
author | ncteisen <ncteisen@gmail.com> | 2017-07-14 16:15:10 -0700 |
---|---|---|
committer | ncteisen <ncteisen@gmail.com> | 2017-08-13 22:30:10 -0700 |
commit | 41ba268c201bc8c861f1ce929ced0f54c3301b10 (patch) | |
tree | 3d0170ef0b47b36803d69c33dcfff7b6077ef5b5 /src/core/lib | |
parent | a27680b597111bc3ddd1272a21be6d35a296b349 (diff) |
Pull bdp estimation into flowctl module
Diffstat (limited to 'src/core/lib')
-rw-r--r-- | src/core/lib/transport/bdp_estimator.c | 10 | ||||
-rw-r--r-- | src/core/lib/transport/bdp_estimator.h | 10 |
2 files changed, 13 insertions, 7 deletions
diff --git a/src/core/lib/transport/bdp_estimator.c b/src/core/lib/transport/bdp_estimator.c index 311ae6390d..8b57693413 100644 --- a/src/core/lib/transport/bdp_estimator.c +++ b/src/core/lib/transport/bdp_estimator.c @@ -33,20 +33,24 @@ void grpc_bdp_estimator_init(grpc_bdp_estimator *estimator, const char *name) { estimator->bw_est = 0; } -bool grpc_bdp_estimator_get_estimate(grpc_bdp_estimator *estimator, +bool grpc_bdp_estimator_get_estimate(const grpc_bdp_estimator *estimator, int64_t *estimate) { *estimate = estimator->estimate; return true; } -bool grpc_bdp_estimator_get_bw(grpc_bdp_estimator *estimator, double *bw) { +bool grpc_bdp_estimator_get_bw(const grpc_bdp_estimator *estimator, + double *bw) { *bw = estimator->bw_est; return true; } -bool grpc_bdp_estimator_add_incoming_bytes(grpc_bdp_estimator *estimator, +void grpc_bdp_estimator_add_incoming_bytes(grpc_bdp_estimator *estimator, int64_t num_bytes) { estimator->accumulator += num_bytes; +} + +bool grpc_bdp_estimator_need_ping(const grpc_bdp_estimator *estimator) { switch (estimator->ping_state) { case GRPC_BDP_PING_UNSCHEDULED: return true; diff --git a/src/core/lib/transport/bdp_estimator.h b/src/core/lib/transport/bdp_estimator.h index a232d1f87f..1ef0dc99dd 100644 --- a/src/core/lib/transport/bdp_estimator.h +++ b/src/core/lib/transport/bdp_estimator.h @@ -47,13 +47,15 @@ typedef struct grpc_bdp_estimator { void grpc_bdp_estimator_init(grpc_bdp_estimator *estimator, const char *name); // Returns true if a reasonable estimate could be obtained -bool grpc_bdp_estimator_get_estimate(grpc_bdp_estimator *estimator, +bool grpc_bdp_estimator_get_estimate(const grpc_bdp_estimator *estimator, int64_t *estimate); -// Returns true if a reasonable estimate could be obtained -bool grpc_bdp_estimator_get_bw(grpc_bdp_estimator *estimator, double *bw); +// Tracks new bytes read. +bool grpc_bdp_estimator_get_bw(const grpc_bdp_estimator *estimator, double *bw); // Returns true if the user should schedule a ping -bool grpc_bdp_estimator_add_incoming_bytes(grpc_bdp_estimator *estimator, +void grpc_bdp_estimator_add_incoming_bytes(grpc_bdp_estimator *estimator, int64_t num_bytes); +// Returns true if the user should schedule a ping +bool grpc_bdp_estimator_need_ping(const grpc_bdp_estimator *estimator); // Schedule a ping: call in response to receiving a true from // grpc_bdp_estimator_add_incoming_bytes once a ping has been scheduled by a // transport (but not necessarily started) |