package fasthttp

import (
	
	
)

func initTimer( *time.Timer,  time.Duration) *time.Timer {
	if  == nil {
		return time.NewTimer()
	}
	if .Reset() {
		// developer sanity-check
		panic("BUG: active timer trapped into initTimer()")
	}
	return 
}

func stopTimer( *time.Timer) {
	if !.Stop() {
		// Collect possibly added time from the channel
		// if timer has been stopped and nobody collected its value.
		select {
		case <-.C:
		default:
		}
	}
}

// AcquireTimer returns a time.Timer from the pool and updates it to
// send the current time on its channel after at least timeout.
//
// The returned Timer may be returned to the pool with ReleaseTimer
// when no longer needed. This allows reducing GC load.
func ( time.Duration) *time.Timer {
	 := timerPool.Get()
	if  == nil {
		return time.NewTimer()
	}
	 := .(*time.Timer)
	initTimer(, )
	return 
}

// ReleaseTimer returns the time.Timer acquired via AcquireTimer to the pool
// and prevents the Timer from firing.
//
// Do not access the released time.Timer or read from its channel otherwise
// data races may occur.
func ( *time.Timer) {
	stopTimer()
	timerPool.Put()
}

var timerPool sync.Pool