A general purpose implementation of the leaky bucket algorithm