pool.go
func (pool *ReaderPool) Get(r io.Reader) (reader io.Reader, release func()) {
	// don't export a ThrottlerReader to prevent users changing the rate
	// and expecting their change to be respected, since we might modify
	// the rate under their feet

	// make the initial rate be 0, the actual rate is
	// set in the call to `setSharedRates`.
	rd := ThrottledReader(r, 0, pool.maxBurst)

	pool.mu.Lock()
	pool.givenOut[rd] = struct{}{}
	pool.setSharedRates()
	pool.mu.Unlock()

	return rd, func() {
		pool.mu.Lock()
		delete(pool.givenOut, rd)
		pool.setSharedRates()
		pool.mu.Unlock()
	}
}
func (pool *ReaderPool) Get(r io.Reader) (reader io.Reader, release func()) {
	// don't export a ThrottlerReader to prevent users changing the rate
	// and expecting their change to be respected, since we might modify
	// the rate under their feet

	// make the initial rate be 0, the actual rate is
	// set in the call to `setSharedRates`.
	rd := ThrottledReader(r, 0, pool.maxBurst)

	pool.mu.Lock()
	pool.givenOut[rd] = struct{}{}
	pool.setSharedRates()
	pool.mu.Unlock()

	return rd, func() {
		pool.mu.Lock()
		delete(pool.givenOut, rd)
		pool.setSharedRates()
		pool.mu.Unlock()
	}
}
func ( pool * ReaderPool ) Get ( r io . Reader ) ( reader io . Reader , release func ( ) ) { // don't export a ThrottlerReader to prevent users changing the rate // and expecting their change to be respected, since we might modify // the rate under their feet // make the initial rate be 0, the actual rate is // set in the call to `setSharedRates`. rd := ThrottledReader ( r , 0 , pool . maxBurst ) pool . mu . Lock ( ) pool . givenOut [ rd ] = struct { } { } pool . setSharedRates ( ) pool . mu . Unlock ( ) return rd , func ( ) { pool . mu . Lock ( ) delete ( pool . givenOut , rd ) pool . setSharedRates ( ) pool . mu . Unlock ( ) } }
// Get a throttled reader that wraps r.
Get a throttled reader that wraps r .