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