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

fmt: enable or block for ch <- x (#7969)

This commit is contained in:
Uwe Krüger
2021-01-08 21:39:21 +01:00
committed by GitHub
parent 2e02a13227
commit 29c2240aef
4 changed files with 39 additions and 5 deletions

View File

@ -4,13 +4,13 @@ const (
num_iterations = 10000
)
fn get_val_from_chan(ch chan i64) ?i64 {
fn get_val_from_chan(ch chan int) ?int {
r := <-ch ?
return r
}
// this function gets an array of channels for `i64`
fn do_rec_calc_send(chs []chan i64, sem sync.Semaphore) {
// this function gets an array of channels for `int`
fn do_rec_calc_send(chs []chan int, sem sync.Semaphore) {
mut msg := ''
for {
mut s := get_val_from_chan(chs[0]) or {
@ -25,10 +25,10 @@ fn do_rec_calc_send(chs []chan i64, sem sync.Semaphore) {
}
fn test_channel_array_mut() {
mut chs := [chan i64{}, chan i64{cap: 10}]
mut chs := [chan int{}, chan int{cap: 10}]
sem := sync.new_semaphore()
go do_rec_calc_send(chs, sem)
mut t := i64(100)
mut t := int(100)
for _ in 0 .. num_iterations {
chs[0] <- t
t = <-chs[1]

0
vlib/sync/channel_try_buf_test.v Executable file → Normal file
View File