修复投影仪控制

This commit is contained in:
2025-03-05 11:03:19 +08:00
parent 363047c078
commit c71e8bc13d
18 changed files with 598 additions and 399 deletions

View File

@@ -3,13 +3,10 @@ package common
import "sync"
type CtrlWait struct {
// 用于暂停的chan
P chan struct{}
// 用于恢复的chan
R chan struct{}
C chan int8
// 状态
s bool
m sync.RWMutex
}
@@ -18,7 +15,7 @@ func (c *CtrlWait) Pause() {
c.m.RLock()
defer c.m.RUnlock()
if c.s {
c.P <- struct{}{}
c.C <- 1
}
}
@@ -27,7 +24,7 @@ func (c *CtrlWait) Resume() {
c.m.RLock()
defer c.m.RUnlock()
if c.s {
c.R <- struct{}{}
c.C <- 0
}
}
@@ -46,8 +43,7 @@ func (c *CtrlWait) Close() {
// NewCtrlWait 创建一个控制等待
func NewCtrlWait() *CtrlWait {
return &CtrlWait{
P: make(chan struct{}),
R: make(chan struct{}),
C: make(chan int8),
s: false,
}
}