From 94b1a1d3836f885b14c5f0e4b6899b17c81217dd Mon Sep 17 00:00:00 2001 From: dudaodong Date: Sat, 1 Jan 2022 20:14:41 +0800 Subject: [PATCH] feat: add Reset func for watcher --- function/watcher.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/function/watcher.go b/function/watcher.go index c7a0b6c..7fd6f92 100644 --- a/function/watcher.go +++ b/function/watcher.go @@ -20,6 +20,7 @@ func (w *Watcher) Stop() { w.stopTime = time.Now().UnixNano() w.excuting = false } + // GetElapsedTime get excute elapsed time. func (w *Watcher) GetElapsedTime() time.Duration { if w.excuting { @@ -27,4 +28,11 @@ func (w *Watcher) GetElapsedTime() time.Duration { } else { return time.Duration(w.stopTime - w.startTime) } -} \ No newline at end of file +} + +// Reset the watch timer. +func (w *Watcher) Reset() { + w.startTime = 0 + w.stopTime = 0 + w.excuting = false +}