Coalescing items in channel
问题 I have a function which receives tasks and puts them into a channel. Every task has ID, some properties and a channel where result will be placed. It looks like this task.Result = make(chan *TaskResult) queue <- task result := <-task.Result sendReponse(result) Another goroutine takes a task from the channel, processes it and puts the result into task's channel task := <-queue task.Result <- doExpensiveComputation(task) This code works fine. But now I want to coalesce tasks in the queue . Task