blob: d992bd4282a99dccc99bff186b51e373a7e386b5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
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()
This goroutine can be used like a watchdog timer
*/
func Watchdog() {
var i = 1
for {
log(logInfo, "watchdog timer is alive. give me something to do.", i)
if (Config.rootNode == nil) {
log(logInfo, "Config.rootNode == nil", i)
} else {
if (logVerbose) {
Config.rootNode.ListChildren(true)
}
}
if (i == 2) {
Config.rootNode.LoadToolkit("gocui")
}
// if (i == 3) {
// Config.rootNode.LoadToolkit("andlabs")
// }
i += 1
time.Sleep(watchtime * time.Second / 10)
}
}
// 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)
}
}
}
*/
|