badger/internal/api/state.go
2023-03-14 09:53:33 +01:00

39 lines
658 B
Go

package api
import "time"
var state State
// unexported function(s)
func runBlocking(function string) bool {
return run(function, true)
}
func run(function string, blocking bool) bool {
if state.blocking {
return false
}
state.functionName = function
state.blocking = blocking
timestamp := time.Now()
state.startTime = timestamp
state.stopTime = timestamp
return true
}
func getRunning() State {
return state
}
func finish() time.Duration {
state.stopTime = time.Now()
return state.stopTime.Sub(state.startTime)
}
// struct(s)
type State struct {
functionName string
blocking bool
startTime time.Time
stopTime time.Time
}