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

sync/channels: use references for chan mut X testcase (#6145)

This commit is contained in:
Uwe Krüger
2020-08-16 23:01:49 +02:00
committed by GitHub
parent 2aedece23d
commit 0c7d73c8b0

View File

@ -6,12 +6,16 @@ const (
struct St { struct St {
mut: mut:
n int dummy i64
dummy2 u32
dummy3 i64
n int
dummy4 int
} }
// this function gets an array of channels for `St` references // this function gets an array of channels for `St` references
fn do_rec_calc_send(chs []chan mut St) { fn do_rec_calc_send(chs []chan mut St) {
mut s := St{} mut s := &St(0)
for { for {
if !(&sync.Channel(chs[0])).pop(&s) { if !(&sync.Channel(chs[0])).pop(&s) {
break break
@ -24,7 +28,7 @@ fn do_rec_calc_send(chs []chan mut St) {
fn test_channel_array_mut() { fn test_channel_array_mut() {
mut chs := [chan mut St{cap: 1}, chan mut St{}] mut chs := [chan mut St{cap: 1}, chan mut St{}]
go do_rec_calc_send(chs) go do_rec_calc_send(chs)
mut t := St{ mut t := &St{
n: 100 n: 100
} }
for _ in 0 .. num_iterations { for _ in 0 .. num_iterations {