Skip to content

Commit 04d8303

Browse files
author
奇淼(piexlmax
authored
Merge pull request #304 from songzhibin97/gva_gormv2_dev
修改了热更正在运行时重启信号的丢弃
2 parents e102f82 + a5e5c58 commit 04d8303

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

server/utils/cmd_Task.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,12 @@ func newT(f func(chan struct{}) error) *T {
7373
//@description: 添加任务
7474

7575
func (t *T) AddTask() {
76-
if len(t.ch) == 1 {
77-
return
78-
}
79-
t.Lock()
80-
defer t.Unlock()
81-
if len(t.ch) == 1 {
76+
select {
77+
case t.ch <- struct{}{}:
78+
default:
8279
// 代表已经有任务了
8380
// 直接丢弃这次任务
84-
return
8581
}
86-
t.ch <- struct{}{}
8782
}
8883

8984
//@author: [songzhibin97](https://github.com/songzhibin97)

0 commit comments

Comments
 (0)