marion 5 tahun lalu
induk
melakukan
cb4ac84bee
1 mengubah file dengan 3 tambahan dan 3 penghapusan
  1. 3 3
      utils/queue/chan_pool.go

+ 3 - 3
utils/queue/chan_pool.go

@@ -32,12 +32,12 @@ func NewChanWorker(workerId, capacity int, workerPool chan chan interface{}) *Ch
 }
 
 func (w *ChanWorker) Start(callback func(workerId int, msg interface{})) {
+	// 新工作管道加入工作管道池
+	w.WorkerPool <- w.JobChannel
+
 	go func(w *ChanWorker, callback func(workerId int, msg interface{})) {
 		defer utils.DefaultGoroutineRecover(nil, `chan池工作对象消息处理`)
 		for {
-			// 新工作管道加入工作管道池
-			w.WorkerPool <- w.JobChannel
-
 			select {
 			case msg := <-w.JobChannel:
 				callback(w.ID, msg)