stop signals to all goroutines to shutdown and reports back when that is complete
(waitShutdown *sync.WaitGroup)
| 125 | // stop signals to all goroutines to shutdown and reports back |
| 126 | // when that is complete |
| 127 | func (rw *readerWriter) stop(waitShutdown *sync.WaitGroup) { |
| 128 | // Schedule the call to Done for once the method returns. |
| 129 | defer waitShutdown.Done() |
| 130 | |
| 131 | log.Printf("%s\t: #####> Stop", rw.name) |
| 132 | |
| 133 | // Close the channel which will causes all the goroutines waiting on |
| 134 | // this channel to receive the notification to shutdown. |
| 135 | close(rw.shutdown) |
| 136 | |
| 137 | // Wait for all the goroutine to call Done on the waitgroup we |
| 138 | // are waiting on. |
| 139 | rw.reportShutdown.Wait() |
| 140 | |
| 141 | log.Printf("%s\t: #####> Stopped", rw.name) |
| 142 | } |
| 143 | |
| 144 | // reader is a goroutine that listens on the shutdown channel and |
| 145 | // performs reads until the channel is signaled. |