You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The example at the doc don't push a channel successfully unless the channel cap is set.
Original code:
structAbc {
x int
}
a:=2.13ch:= chan f64{}
res:= ch.try_push(a) // try to perform `ch <- a`println(res)
l:= ch.len // number of elements in queuec:= ch.cap // maximum queue lengthis_closed:= ch.closed // bool flag - has `ch` been closedprintln(l)
println(c)
mutb:= Abc{}
ch2:= chan Abc{}
res2:= ch2.try_pop(mut b) // try to perform `b = <-ch2`
Produces
not_ready
0
0
With the following change:
ch:= chan f64{ cap:1 }
Produces what we expect:
success
1
1
Don't know if default capacity should not be zero (bug) or not. When you adapt this code for you don't get receptions. Then debug and found result not_ready and then when you set the capacity you get your messages.
Describe the issue
The example at the doc don't push a channel successfully unless the channel cap is set.
Original code:
Produces
With the following change:
Produces what we expect:
Don't know if default capacity should not be zero (bug) or not. When you adapt this code for you don't get receptions. Then debug and found result not_ready and then when you set the capacity you get your messages.
Links
https://docs.vlang.io/concurrency.html#special-channel-features
Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.
The text was updated successfully, but these errors were encountered: