mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
Fix news_fetcher example
News_fetcher now uses proper numbering with mutex lock instead of the cursor
This commit is contained in:
parent
13e1b4edb1
commit
4f11185231
@ -21,6 +21,7 @@ mut:
|
|||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
ids []int
|
ids []int
|
||||||
cursor int
|
cursor int
|
||||||
|
list_id int
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (f mut Fetcher) fetch() {
|
fn (f mut Fetcher) fetch() {
|
||||||
@ -37,7 +38,11 @@ fn (f mut Fetcher) fetch() {
|
|||||||
println('failed to decode a story')
|
println('failed to decode a story')
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
println('#$f.cursor) $story.title | $story.url')
|
f.mu.lock()
|
||||||
|
f.list_id++
|
||||||
|
cursor := f.list_id
|
||||||
|
f.mu.unlock()
|
||||||
|
println('#$cursor) $story.title | $story.url')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user