mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
Add sanity check to end of DispatchLoop
This commit is contained in:
parent
62144e7fb1
commit
27c2529c1a
1 changed files with 16 additions and 0 deletions
16
dispatch.go
16
dispatch.go
|
@ -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.
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue