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

sync: use asserts in channel code only when -d debug is passed

This commit is contained in:
Delyan Angelov 2022-04-14 14:00:57 +03:00
parent a62560d2c1
commit f1f75897b3
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
2 changed files with 7 additions and 3 deletions

View File

@ -41,7 +41,9 @@ fn main() {
go do_rec(ch, resch, n)
no -= n
}
$if debug {
assert no == 0
}
no = nobj
for i in 0 .. nsend {
n := no / (nsend - i)

View File

@ -547,8 +547,10 @@ fn (mut ch Channel) try_pop_priv(dest voidptr, no_block bool) ChanState {
// -2 if all channels are closed
pub fn channel_select(mut channels []&Channel, dir []Direction, mut objrefs []voidptr, timeout time.Duration) int {
$if debug {
assert channels.len == dir.len
assert dir.len == objrefs.len
}
mut subscr := []Subscription{len: channels.len}
mut sem := unsafe { Semaphore{} }
sem.init(0)