修复投影仪控制
This commit is contained in:
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user