mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-23 13:52:26 +08:00
feat: add Reset func for watcher
This commit is contained in:
@@ -20,6 +20,7 @@ func (w *Watcher) Stop() {
|
|||||||
w.stopTime = time.Now().UnixNano()
|
w.stopTime = time.Now().UnixNano()
|
||||||
w.excuting = false
|
w.excuting = false
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetElapsedTime get excute elapsed time.
|
// GetElapsedTime get excute elapsed time.
|
||||||
func (w *Watcher) GetElapsedTime() time.Duration {
|
func (w *Watcher) GetElapsedTime() time.Duration {
|
||||||
if w.excuting {
|
if w.excuting {
|
||||||
@@ -28,3 +29,10 @@ func (w *Watcher) GetElapsedTime() time.Duration {
|
|||||||
return time.Duration(w.stopTime - w.startTime)
|
return time.Duration(w.stopTime - w.startTime)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reset the watch timer.
|
||||||
|
func (w *Watcher) Reset() {
|
||||||
|
w.startTime = 0
|
||||||
|
w.stopTime = 0
|
||||||
|
w.excuting = false
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user