派生自 libgowrapper/face

zhangmeng
2020-01-15 372e4a07b802f5966acc76d80179ee5569886e6f
bug fixed
1个文件已修改
45 ■■■■■ 已修改文件
run.go 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
run.go
@@ -2,7 +2,6 @@
import (
    "context"
    "os"
    "sync"
    "time"
@@ -10,8 +9,6 @@
    "basic.com/valib/gogpu.git"
)
const maxTryBeforeReboot = 10
type face struct {
    handle *SDKFace
@@ -30,40 +27,6 @@
    ipc2Rule            string
    ruleMsgMaxCacheSize int
    reserved            map[string]interface{}
    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
@@ -149,9 +112,6 @@
        ipc2Rule:            ipc2Rule,
        ruleMsgMaxCacheSize: ruleMaxSize,
        reserved:            reserved,
        running:     true,
        rebootUntil: maxTryBeforeReboot,
    }
}
@@ -185,8 +145,6 @@
    go torule.Run(ctx)
    go s.run(ctx, chRcv, chSnd)
    go s.maybeReboot(ctx)
}
//////////////////////////////////////////////////////////////////
@@ -301,9 +259,6 @@
            count, data, _ := f.handle.Run(i.Data, imgW, imgH, 3, dtchn)
            common.EjectResult(data, rMsg, out)
            f.mtxRunning.Lock()
            f.running = true
            f.mtxRunning.Unlock()
            var id, name string
            if rMsg.Msg.Tasklab != nil {