Browse Source

Merge pull request #304 from songzhibin97/gva_gormv2_dev

修改了热更正在运行时重启信号的丢弃
奇淼(piexlmax 4 years ago
parent
commit
8aae01defb
1 changed files with 3 additions and 8 deletions
  1. 3 8
      server/utils/cmd_Task.go

+ 3 - 8
server/utils/cmd_Task.go

@@ -73,17 +73,12 @@ func newT(f func(chan struct{}) error) *T {
 //@description: 添加任务
 
 func (t *T) AddTask() {
-	if len(t.ch) == 1 {
-		return
-	}
-	t.Lock()
-	defer t.Unlock()
-	if len(t.ch) == 1 {
+	select {
+	case t.ch <- struct{}{}:
+	default:
 		// 代表已经有任务了
 		// 直接丢弃这次任务
-		return
 	}
-	t.ch <- struct{}{}
 }
 
 //@author: [songzhibin97](https://github.com/songzhibin97)