package coroutine type Fixed struct { queues chan struct{} } func NewFixed(count int) *Fixed { return &Fixed{ queues: make(chan struct{}, count), } } // Run 运行指定函数 // name 协程名称 // fn 协程执行的函数 func (f *Fixed) Run(name string, fn func()) { f.queues <- struct{}{} runAfter(name, fn, func() { <-f.queues }) } // chan 的发送次数 >= 接收次数,可以不用close,由GC回收