1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 07:14:47 -05:00

Add sanity check to end of DispatchLoop

This commit is contained in:
Ryan Dahl 2018-05-29 02:51:55 -04:00
parent 62144e7fb1
commit 27c2529c1a

View file

@ -108,6 +108,7 @@ func DispatchLoop() {
wg.Done() // Corresponds to the wg.Add(1) in Pub().
case <-doneChan:
// All goroutines have completed. Now we can exit main().
checkChanEmpty()
return
}
@ -120,3 +121,18 @@ func DispatchLoop() {
first = false
}
}
func checkChanEmpty() {
// We've received a done event. As a sanity check, make sure that resChan is
// empty.
select {
case _, ok := <-resChan:
if ok {
panic("Read a message from resChan after doneChan closed.")
} else {
panic("resChan closed. Unexpected.")
}
default:
// No value ready, moving on.
}
}