mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-14 23:16:49 +00:00
* basic implementation * log: deprecate duplicate function, add tests and refine calls. * linter: fixes * linter: update struct * linter and new type * log tests: update to not lint issue * linter: stop complaining please * glorious: nits * log: rm comment code * glorious: nits * glorious: nits * glorious: nits * glorious: nits missed --------- Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
31 lines
463 B
Go
31 lines
463 B
Go
package vm
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/thrasher-corp/gocryptotrader/log"
|
|
)
|
|
|
|
func (vm *VM) runner() {
|
|
vm.S = make(chan struct{}, 1)
|
|
waitTime := time.NewTicker(vm.T)
|
|
vm.NextRun = time.Now().Add(vm.T)
|
|
|
|
go func() {
|
|
for {
|
|
select {
|
|
case <-waitTime.C:
|
|
vm.NextRun = time.Now().Add(vm.T)
|
|
err := vm.RunCtx()
|
|
if err != nil {
|
|
log.Errorln(log.GCTScriptMgr, err)
|
|
return
|
|
}
|
|
case <-vm.S:
|
|
waitTime.Stop()
|
|
return
|
|
}
|
|
}
|
|
}()
|
|
}
|