diff --git a/examples/news_fetcher.v b/examples/news_fetcher.v index dce80a2487..5b390a62ff 100644 --- a/examples/news_fetcher.v +++ b/examples/news_fetcher.v @@ -67,7 +67,7 @@ fn main() { wg := sync.new_waitgroup() mtx := sync.new_mutex() - mut fetcher := &Fetcher{ids: ids} + mut fetcher := &Fetcher{ids: ids mu: 0 wg: 0} fetcher.mu = &mtx fetcher.wg = &wg fetcher.wg.add(ids.len) diff --git a/vlib/sync/waitgroup.v b/vlib/sync/waitgroup.v index 307192e824..35a8f358a6 100644 --- a/vlib/sync/waitgroup.v +++ b/vlib/sync/waitgroup.v @@ -32,7 +32,12 @@ pub fn (wg mut WaitGroup) done() { pub fn (wg mut WaitGroup) wait() { for wg.active > 0 { - // waiting + // Do not remove this, busy empty loops are optimized + // with -prod by some compilers, see issue #2874 + $if windows { + C.Sleep(1) + } $else { + C.usleep(1000) + } } } -