nl_tokens: Takes several things ( eg . bytes ) . This method blocks until at least one thing can be used according to the current rate and prescaling settings .
pl_tokens: public int take ( int n ) { int lenToTake ; while ( true ) { int stored = spent . get ( ) ; lenToTake = Math . <mask> ( n , thingsPerTick - stored ) ; if ( stored >= thingsPerTick ) sleep ( ) ; else if ( spent . compareAndSet ( stored , stored + lenToTake ) ) break ; } timewiseAvailable -= lenToTake ; return lenToTake ; }