MCPcopy Create free account
hub / github.com/goinaction/code / stop

Method stop

chapter7/patterns/semaphore/semaphore.go:127–142  ·  view source on GitHub ↗

stop signals to all goroutines to shutdown and reports back when that is complete

(waitShutdown *sync.WaitGroup)

Source from the content-addressed store, hash-verified

125// stop signals to all goroutines to shutdown and reports back
126// when that is complete
127func (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.

Callers 1

shutdownFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected