this will block and not close if the len(msgs) is larger than the channel buffer.
()
| 51 | |
| 52 | // this will block and not close if the len(msgs) is larger than the channel buffer. |
| 53 | func (wp *workerPool) queueMessages() { |
| 54 | msgs := getMessages() |
| 55 | for _, msg := range msgs { |
| 56 | // add messages to string channel |
| 57 | wp.msgs <- msg |
| 58 | } |
| 59 | |
| 60 | // close the worker channel and signal there won't be any more data |
| 61 | close(wp.msgs) |
| 62 | } |
| 63 | |
| 64 | func (wp workerPool) detectWords() int { |
| 65 | var numWordsDetected int |