派生自 libgowrapper/face

zhangmeng
2020-01-15 677aeb36d939c7425e09b72cb20bed701951e5a2
debug
1个文件已删除
1个文件已修改
110 ■■■■■ 已修改文件
common/reboot.go 64 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
run.go 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
common/reboot.go
File was deleted
run.go
@@ -2,6 +2,7 @@
import (
    "context"
    "os"
    "sync"
    "time"
    "unsafe"
@@ -12,6 +13,8 @@
    "basic.com/valib/gogpu.git"
    "github.com/gogo/protobuf/proto"
)
const maxTryBeforeReboot = 10
type face struct {
    handle *SDKFace
@@ -31,7 +34,39 @@
    ruleMsgMaxCacheSize int
    reserved            map[string]interface{}
    stopper *common.Disturber
    running     bool
    rebootUntil int
    mtxRunning  sync.Mutex
}
func (f *face) maybeReboot(ctx context.Context) {
    for {
        select {
        case <-ctx.Done():
            return
        default:
            f.mtxRunning.Lock()
            running := f.running
            f.mtxRunning.Unlock()
            if running {
                f.rebootUntil = 0
                f.mtxRunning.Lock()
                f.running = false
                f.mtxRunning.Unlock()
            } else {
                f.rebootUntil++
                f.fnLogger("Face No Running: ", f.rebootUntil)
                if f.rebootUntil > maxTryBeforeReboot {
                    f.fnLogger("Face Too Long Running, Reboot")
                    os.Exit(0)
                }
            }
            time.Sleep(time.Second)
        }
    }
}
// Create create sdk
@@ -118,7 +153,8 @@
        ruleMsgMaxCacheSize: ruleMaxSize,
        reserved:            reserved,
        stopper: common.NewDisturber(10),
        running:     true,
        rebootUntil: maxTryBeforeReboot,
    }
}
@@ -153,7 +189,7 @@
    go s.run(ctx, chRcv, chSnd)
    go s.stopper.MaybeReboot(ctx, s.fnLogger)
    go s.maybeReboot(ctx)
}
//////////////////////////////////////////////////////////////////
@@ -316,7 +352,9 @@
            // f.fnLogger("Face~~~EjectResult", dtchn)
            common.EjectResult(data, rMsg, out)
            // f.fnLogger("Face~~~EjectResult Over", dtchn)
            f.stopper.Prevent()
            f.mtxRunning.Lock()
            f.running = true
            f.mtxRunning.Unlock()
            var id, name string
            if rMsg.Msg.Tasklab != nil {