]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
autoskip写竞争
authorqydysky <qydysky@foxmail.com>
Wed, 20 Jan 2021 08:53:28 +0000 (16:53 +0800)
committerqydysky <qydysky@foxmail.com>
Wed, 20 Jan 2021 08:53:28 +0000 (16:53 +0800)
Reply/F.go

index d96b241c07120dbaf9d5719c7bbc4d7fec5fa7f1..a5be923fbeb48959efcb959264767dc3b3fdbc65 100644 (file)
@@ -508,6 +508,7 @@ type Autoskip struct {
        buf map[string]Autoskip_item
        now uint
        ticker *time.Ticker
+       sync.Mutex
 }
 
 type Autoskip_item struct {
@@ -528,7 +529,9 @@ func init(){
                        autoskip.now += 1
                        for k,v := range autoskip.buf{
                                if v.Exprie <= autoskip.now {
+                                       autoskip.Lock()
                                        delete(autoskip.buf,k)
+                                       autoskip.Unlock()
                                        {//超时显示
                                                if v.Num > 3 {
                                                        Msg_showdanmu(nil, strconv.Itoa(int(v.Num)) + " x " + k,`0multi`)
@@ -544,6 +547,8 @@ func init(){
 
 func Autoskipf(s string) uint {
        if !IsOn("Autoskip") || s == ""{return 0}
+       autoskip.Lock()
+       defer autoskip.Unlock()
        {//验证是否已经存在
                if v,ok := autoskip.buf[s];ok && autoskip.now < v.Exprie{
                        autoskip.buf[s] = Autoskip_item{