Add a helper function to decrement read and write at the same time

This commit is contained in:
Nick Mathewson 2018-04-10 12:33:30 -04:00
parent c376200f6a
commit 8a85239746
2 changed files with 14 additions and 0 deletions

View File

@ -178,3 +178,14 @@ token_bucket_dec_write(token_bucket_t *bucket,
return decrement_single_bucket(&bucket->write_bucket, n);
}
/**
* As token_bucket_dec_read and token_bucket_dec_write, in a single operation.
*/
void
token_bucket_dec(token_bucket_t *bucket,
ssize_t n_read, ssize_t n_written)
{
token_bucket_dec_read(bucket, n_read);
token_bucket_dec_read(bucket, n_written);
}

View File

@ -43,6 +43,9 @@ int token_bucket_dec_read(token_bucket_t *bucket,
int token_bucket_dec_write(token_bucket_t *bucket,
ssize_t n);
void token_bucket_dec(token_bucket_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_get_read(const token_bucket_t *bucket)