播放游戏时,停止待机任务

This commit is contained in:
2025-02-26 19:45:47 +08:00
parent 8b080a8081
commit 593d7758bf
19 changed files with 422 additions and 275 deletions

29
internal/common/pause.go Normal file
View File

@@ -0,0 +1,29 @@
package common
type CtrlWait struct {
// 用于暂停的chan
P chan struct{}
// 用于恢复的chan
R chan struct{}
}
// Pause 暂停
func (c *CtrlWait) Pause() {
c.P <- struct{}{}
}
// Resume 恢复
func (c *CtrlWait) Resume() {
c.R <- struct{}{}
}
// NewCtrlWait 创建一个控制等待
func NewCtrlWait() *CtrlWait {
return &CtrlWait{
P: make(chan struct{}),
R: make(chan struct{}),
}
}
// PassCtrl 全局控制等待
var PassCtrl = NewCtrlWait()