项目结构更新

This commit is contained in:
JACKYMYPERSON
2025-09-15 11:09:22 +08:00
parent 2ab7614ea0
commit 8ccf028ae4
25 changed files with 608 additions and 17 deletions

View File

@@ -0,0 +1,27 @@
package goroutine
import (
"fmt"
"sync"
"toutoukan/model/routine"
)
func NewConsumer(ch chan routine.Task, wg *sync.WaitGroup, done chan struct{}, num int, data *routine.Data, rwmutex *sync.RWMutex) {
defer wg.Done()
for {
select {
case <-ch:
rwmutex.RLock()
fmt.Printf("消费者%d号处理消息统计消息总数为%d\n", num+1, data.Count)
fmt.Printf("消费者%d号当前记录详情如下\n", num+1)
for key, value := range data.Record {
fmt.Printf(" 键:%d%d\n", key, value)
}
rwmutex.RUnlock()
case <-done:
fmt.Printf("消费者%d号退出接收\n", num+1)
return
}
}
}