Subject: | Patch: method for get current tokens count |
Simple patch that add method for get current tokens count
Subject: | get_tokens_count_patch.diff |
--- /usr/local/lib/perl5/site_perl/5.10.1/Algorithm/TokenBucket.pm.orig 2012-10-17 16:32:22.000000000 +0400
+++ /usr/local/lib/perl5/site_perl/5.10.1/Algorithm/TokenBucket.pm 2012-10-17 16:37:30.000000000 +0400
@@ -161,6 +161,18 @@ sub conform {
return $self->{_tokens} >= $size;
}
+=item get()
+
+Returns count of tokens in bucket
+
+=cut
+
+sub get {
+ my Algorithm::TokenBucket $self = shift;
+ $self->_token_flow;
+ return $self->{_tokens};
+}
+
=item count($)
This sub removes I<N> (or all if there are less than I<N> available) tokens from the bucket.