this will block and not close if the len(msgs) is larger than the channel buffer.
()
| 37 | |
| 38 | // this will block and not close if the len(msgs) is larger than the channel buffer. |
| 39 | func (wp *workerPool) queueMessages() { |
| 40 | msgs := getMessages() |
| 41 | for _, msg := range msgs { |
| 42 | // add messages to string channel |
| 43 | wp.msgs <- msg |
| 44 | } |
| 45 | |
| 46 | // close the worker channel and signal there won't be any more data |
| 47 | close(wp.msgs) |
| 48 | } |
| 49 | |
| 50 | func (wp workerPool) detectWords() int { |
| 51 | var numWordsDetected int |