1
This commit is contained in:
@@ -130,7 +130,8 @@ type TcpClient struct {
|
||||
Clients map[string]*PrintInfo //放tcp连接的,printNo 为key
|
||||
MsgMap map[string]chan *model.PrintMsg //放打印信息的,printNo为key
|
||||
CallBackMap map[string]chan string //放打印信息回调信息的,printNo为key
|
||||
TimeoutMap map[string]chan bool //退出channel
|
||||
//TimeoutMap map[string]chan bool //退出channel
|
||||
TimeoutMap map[string]bool //退出channel
|
||||
*sync.RWMutex
|
||||
}
|
||||
|
||||
@@ -177,14 +178,16 @@ func (t *TcpClient) buildCallBackMap(key string) {
|
||||
func (t *TcpClient) buildTimeoutMap(key string) {
|
||||
t.Lock()
|
||||
defer t.Unlock()
|
||||
dataChan := make(chan bool)
|
||||
t.TimeoutMap[key] = dataChan
|
||||
//dataChan := make(chan bool)
|
||||
//t.TimeoutMap[key] = dataChan
|
||||
t.TimeoutMap[key] = true
|
||||
}
|
||||
|
||||
func (t *TcpClient) getTimeOut(key string) bool {
|
||||
t.RLock()
|
||||
defer t.RUnlock()
|
||||
return <-t.TimeoutMap[key]
|
||||
//return <-t.TimeoutMap[key]
|
||||
return t.TimeoutMap[key]
|
||||
}
|
||||
|
||||
func (t *TcpClient) buildAllMap(key string) {
|
||||
@@ -192,7 +195,7 @@ func (t *TcpClient) buildAllMap(key string) {
|
||||
defer t.Unlock()
|
||||
t.MsgMap[key] = make(chan *model.PrintMsg, 1024)
|
||||
t.CallBackMap[key] = make(chan string, 1024)
|
||||
t.TimeoutMap[key] = make(chan bool, 1)
|
||||
t.TimeoutMap[key] = true
|
||||
}
|
||||
|
||||
func (t *TcpClient) getPrintStatus(key string) int {
|
||||
@@ -332,7 +335,7 @@ func NewTcpClient() *TcpClient {
|
||||
Clients: make(map[string]*PrintInfo),
|
||||
CallBackMap: make(map[string]chan string),
|
||||
MsgMap: make(map[string]chan *model.PrintMsg),
|
||||
TimeoutMap: make(map[string]chan bool),
|
||||
TimeoutMap: make(map[string]bool, 0),
|
||||
}
|
||||
t.RWMutex = new(sync.RWMutex)
|
||||
return t
|
||||
|
||||
Reference in New Issue
Block a user