diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-04-13 10:51:59 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-04-13 10:54:26 -0400 |
commit | 03b96882deb60cd21c3c77746f4f9cd4aac0a724 (patch) | |
tree | dc9f65dc453aa4d0eb468e74880fded889f4bd8e /src/common/token_bucket.h | |
parent | b152d62cee7480ee7b9b68dd9b619db65b6cd112 (diff) | |
download | tor-03b96882deb60cd21c3c77746f4f9cd4aac0a724.tar.gz tor-03b96882deb60cd21c3c77746f4f9cd4aac0a724.zip |
Rename token_bucket_t to token_bucket_rw_t.
This is a simple search-and-replace to rename the token bucket type
to indicate that it contains both a read and a write bucket, bundled
with their configuration. It's preliminary to refactoring the
bucket type.
Diffstat (limited to 'src/common/token_bucket.h')
-rw-r--r-- | src/common/token_bucket.h | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/src/common/token_bucket.h b/src/common/token_bucket.h index 2d1ccd5cf3..f9d04f79a5 100644 --- a/src/common/token_bucket.h +++ b/src/common/token_bucket.h @@ -2,8 +2,8 @@ /* See LICENSE for licensing information */ /** - * \file token_bucket.h - * \brief Headers for token_bucket.c + * \file token_bucket_rw.h + * \brief Headers for token_bucket_rw.c **/ #ifndef TOR_TOKEN_BUCKET_H @@ -11,52 +11,53 @@ #include "torint.h" -typedef struct token_bucket_t { +typedef struct token_bucket_rw_t { uint32_t rate; int32_t burst; int32_t read_bucket; int32_t write_bucket; uint32_t last_refilled_at_ts; -} token_bucket_t; +} token_bucket_rw_t; -#define TOKEN_BUCKET_MAX_BURST INT32_MAX +#define TOKEN_BUCKET_RW_MAX_BURST INT32_MAX -void token_bucket_init(token_bucket_t *bucket, +void token_bucket_rw_init(token_bucket_rw_t *bucket, uint32_t rate, uint32_t burst, uint32_t now_ts); -void token_bucket_adjust(token_bucket_t *bucket, +void token_bucket_rw_adjust(token_bucket_rw_t *bucket, uint32_t rate, uint32_t burst); -void token_bucket_reset(token_bucket_t *bucket, +void token_bucket_rw_reset(token_bucket_rw_t *bucket, uint32_t now_ts); #define TB_READ 1 #define TB_WRITE 2 -int token_bucket_refill(token_bucket_t *bucket, +int token_bucket_rw_refill(token_bucket_rw_t *bucket, uint32_t now_ts); -int token_bucket_dec_read(token_bucket_t *bucket, +int token_bucket_rw_dec_read(token_bucket_rw_t *bucket, ssize_t n); -int token_bucket_dec_write(token_bucket_t *bucket, +int token_bucket_rw_dec_write(token_bucket_rw_t *bucket, ssize_t n); -void token_bucket_dec(token_bucket_t *bucket, +void token_bucket_rw_dec(token_bucket_rw_t *bucket, ssize_t n_read, ssize_t n_written); -static inline size_t token_bucket_get_read(const token_bucket_t *bucket); +static inline size_t token_bucket_rw_get_read(const token_bucket_rw_t *bucket); static inline size_t -token_bucket_get_read(const token_bucket_t *bucket) +token_bucket_rw_get_read(const token_bucket_rw_t *bucket) { const ssize_t b = bucket->read_bucket; return b >= 0 ? b : 0; } -static inline size_t token_bucket_get_write(const token_bucket_t *bucket); +static inline size_t token_bucket_rw_get_write( + const token_bucket_rw_t *bucket); static inline size_t -token_bucket_get_write(const token_bucket_t *bucket) +token_bucket_rw_get_write(const token_bucket_rw_t *bucket) { const ssize_t b = bucket->write_bucket; return b >= 0 ? b : 0; |