2022-11-13 08:53:03 -06:00
|
|
|
package gui
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
var watchtime time.Duration = 100 // in tenths of seconds
|
|
|
|
|
|
|
|
/*
|
|
|
|
This program sits here.
|
|
|
|
If you exit here, the whole thing will os.Exit()
|
2023-04-28 10:35:57 -05:00
|
|
|
TODO: use Ticker
|
2022-11-13 08:53:03 -06:00
|
|
|
|
|
|
|
This goroutine can be used like a watchdog timer
|
|
|
|
*/
|
|
|
|
func Watchdog() {
|
|
|
|
var i = 1
|
|
|
|
for {
|
2023-04-28 10:35:57 -05:00
|
|
|
log(logInfo, "gui.Watchdog() is alive. give me something to do.", i)
|
|
|
|
if (me.rootNode == nil) {
|
|
|
|
log(logInfo, "me.rootNode == nil", i)
|
2023-04-07 09:18:03 -05:00
|
|
|
} else {
|
|
|
|
if (logVerbose) {
|
2023-04-28 10:35:57 -05:00
|
|
|
me.rootNode.ListChildren(true)
|
2023-04-07 09:18:03 -05:00
|
|
|
}
|
|
|
|
}
|
2022-11-13 08:53:03 -06:00
|
|
|
i += 1
|
|
|
|
time.Sleep(watchtime * time.Second / 10)
|
|
|
|
}
|
|
|
|
}
|
2023-04-07 18:16:16 -05:00
|
|
|
// https://www.reddit.com/r/golang/comments/12em87q/how_to_run_periodic_tasks/
|
|
|
|
/*
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
ticker := time.NewTicker(time.Second)
|
|
|
|
defer ticker.Stop()
|
|
|
|
done := make(chan bool)
|
|
|
|
go func() {
|
|
|
|
time.Sleep(10 * time.Second)
|
|
|
|
done <- true
|
|
|
|
}()
|
|
|
|
for {
|
|
|
|
select {
|
|
|
|
case <-done:
|
|
|
|
fmt.Println("Done!")
|
|
|
|
return
|
|
|
|
case t := <-ticker.C:
|
|
|
|
fmt.Println("Current time: ", t)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|