807afe48a8
runtime.nanotime is significantly faster than time.Now. Use it unless build tags prevent usage of unsafe. Change LastUsedTime to LastUsedNanotime as a time.Time is no longer available. Add IdleDuration to make it more convenient to get the time a resource has been idle. Rename ReleaseIdle to ReleaseUnused to better indicate it is releasing the resource without using it rather than that it is releasing a resource acquired with AcquireAllIdle. Refactor tests of usage tracking to not be intermingled with AcquireAllIdle tests.
14 lines
200 B
Go
14 lines
200 B
Go
// +build purego appengine js
|
|
|
|
// This file contains the safe implementation of nanotime using time.Now().
|
|
|
|
package puddle
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
func nanotime() int64 {
|
|
return time.Now().UnixNano()
|
|
}
|