mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: enable module auto import (of sync
) (#6271)
This commit is contained in:
@ -1,23 +1,19 @@
|
||||
import sync
|
||||
|
||||
const (
|
||||
num_iterations = 10000
|
||||
)
|
||||
|
||||
fn do_send(mut ch sync.Channel) {
|
||||
fn do_send(ch chan int) {
|
||||
for i in 0 .. num_iterations {
|
||||
ch.push(&i)
|
||||
ch <- i
|
||||
}
|
||||
}
|
||||
|
||||
fn test_channel_unbuffered() {
|
||||
mut ch := sync.new_channel<int>(0)
|
||||
go do_send(mut ch)
|
||||
ch := chan int{}
|
||||
go do_send(ch)
|
||||
mut sum := i64(0)
|
||||
for _ in 0 .. num_iterations {
|
||||
a := 0
|
||||
ch.pop(&a)
|
||||
sum += a
|
||||
sum += <-ch
|
||||
}
|
||||
assert sum == u64(num_iterations)*(num_iterations-1)/2
|
||||
}
|
||||
|
Reference in New Issue
Block a user