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:

committed by
Alexander Medvednikov

parent
4a506b0566
commit
32683ad6fd
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user