1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

sync: fix mutex on win & waitgroup (all os) update. fixes news_fetcher example on win (#1776)

This commit is contained in:
joe-conigliaro
2019-08-29 18:48:03 +10:00
committed by Alexander Medvednikov
parent 4a506b0566
commit 32683ad6fd
3 changed files with 60 additions and 87 deletions

View File

@@ -25,15 +25,14 @@ mut:
fn (f mut Fetcher) fetch() {
for {
f.mu.lock()
if f.cursor >= f.ids.len {
f.mu.unlock()
return
}
id := f.ids[f.cursor]
f.mu.lock()
f.cursor++
cursor := f.cursor
f.mu.unlock()
cursor := f.cursor
resp := http.get('https://hacker-news.firebaseio.com/v0/item/${id}.json') or {
println('failed to fetch data from /v0/item/${id}.json')
exit(1)
@@ -42,8 +41,8 @@ fn (f mut Fetcher) fetch() {
println('failed to decode a story')
exit(1)
}
f.wg.done()
println('#$cursor) $story.title | $story.url')
f.wg.done()
}
}