summaryrefslogtreecommitdiff
path: root/src/common/token_bucket.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-04-13 12:03:29 -0400
committerNick Mathewson <nickm@torproject.org>2018-04-13 16:31:47 -0400
commit003e6595bf355fd13f85eb31e7850cec086ecd07 (patch)
tree863d49e61461037271d128f285e19b4a0fa096c4 /src/common/token_bucket.h
parent2307bef7a2403a48d57e3e352d8befcd8c9f482e (diff)
downloadtor-003e6595bf355fd13f85eb31e7850cec086ecd07.tar.gz
tor-003e6595bf355fd13f85eb31e7850cec086ecd07.zip
Refactor "timestamp" not to be its own type coupled to token buffers
Really, the uint32_t is only an optimization; any kind of unit should work fine. Some users might want to use time_t or monotime_coarse_t or something like that.
Diffstat (limited to 'src/common/token_bucket.h')
-rw-r--r--src/common/token_bucket.h12
1 files changed, 2 insertions, 10 deletions
diff --git a/src/common/token_bucket.h b/src/common/token_bucket.h
index 2507cd225b..44315fb6bd 100644
--- a/src/common/token_bucket.h
+++ b/src/common/token_bucket.h
@@ -27,12 +27,6 @@ typedef struct token_bucket_raw_t {
int32_t bucket;
} token_bucket_raw_t;
-/** A timestamp for a token bucket. The units of this timestamp are
- * unspecified, but must match with the rate set in the token_bucket_cfg_t. */
-typedef struct token_bucket_timestamp_t {
- uint32_t last_refilled_at;
-} token_bucket_timestamp_t;
-
void token_bucket_cfg_init(token_bucket_cfg_t *cfg,
uint32_t rate,
uint32_t burst);
@@ -41,9 +35,7 @@ void token_bucket_raw_adjust(token_bucket_raw_t *bucket,
const token_bucket_cfg_t *cfg);
void token_bucket_raw_reset(token_bucket_raw_t *bucket,
- token_bucket_timestamp_t *stamp,
- const token_bucket_cfg_t *cfg,
- uint32_t now);
+ const token_bucket_cfg_t *cfg);
int token_bucket_raw_dec(token_bucket_raw_t *bucket,
ssize_t n);
@@ -67,7 +59,7 @@ typedef struct token_bucket_rw_t {
token_bucket_cfg_t cfg;
token_bucket_raw_t read_bucket;
token_bucket_raw_t write_bucket;
- token_bucket_timestamp_t stamp;
+ uint32_t last_refilled_at_timestamp;
} token_bucket_rw_t;
void token_bucket_rw_init(token_bucket_rw_t *bucket,