sync: use asserts in channel code only when `-d debug` is passed
parent
a62560d2c1
commit
f1f75897b3
|
@ -41,7 +41,9 @@ fn main() {
|
||||||
go do_rec(ch, resch, n)
|
go do_rec(ch, resch, n)
|
||||||
no -= n
|
no -= n
|
||||||
}
|
}
|
||||||
|
$if debug {
|
||||||
assert no == 0
|
assert no == 0
|
||||||
|
}
|
||||||
no = nobj
|
no = nobj
|
||||||
for i in 0 .. nsend {
|
for i in 0 .. nsend {
|
||||||
n := no / (nsend - i)
|
n := no / (nsend - i)
|
||||||
|
|
|
@ -547,8 +547,10 @@ fn (mut ch Channel) try_pop_priv(dest voidptr, no_block bool) ChanState {
|
||||||
// -2 if all channels are closed
|
// -2 if all channels are closed
|
||||||
|
|
||||||
pub fn channel_select(mut channels []&Channel, dir []Direction, mut objrefs []voidptr, timeout time.Duration) int {
|
pub fn channel_select(mut channels []&Channel, dir []Direction, mut objrefs []voidptr, timeout time.Duration) int {
|
||||||
|
$if debug {
|
||||||
assert channels.len == dir.len
|
assert channels.len == dir.len
|
||||||
assert dir.len == objrefs.len
|
assert dir.len == objrefs.len
|
||||||
|
}
|
||||||
mut subscr := []Subscription{len: channels.len}
|
mut subscr := []Subscription{len: channels.len}
|
||||||
mut sem := unsafe { Semaphore{} }
|
mut sem := unsafe { Semaphore{} }
|
||||||
sem.init(0)
|
sem.init(0)
|
||||||
|
|
Loading…
Reference in New Issue