There's a bug that was discovered in #19 regarding the multi-threaded implementation starting with a full token bucket (really empty mpsc queue of size capacity). This can cause inaccurate rates at start until all capacity worth of tokens are consumed.
Two possible fixes. Option 1 - fill the mpsc queue with empty tokens on initialization - this causes the senders to be unable to push tokens onto the queue until the limiter has consumed them. Option 2 - use an mpmc queue in the "correct" direction. This will probably make the code easier to read, but at the cost of a dependency.
There's a bug that was discovered in #19 regarding the multi-threaded implementation starting with a full token bucket (really empty mpsc queue of size capacity). This can cause inaccurate rates at start until all capacity worth of tokens are consumed.
Two possible fixes. Option 1 - fill the mpsc queue with empty tokens on initialization - this causes the senders to be unable to push tokens onto the queue until the limiter has consumed them. Option 2 - use an mpmc queue in the "correct" direction. This will probably make the code easier to read, but at the cost of a dependency.