That is not a general idiom. That is a specialized case that maps the buffer
size on a channel to the size of an ancillary structure.
In general if you are spinning waiting for channels you’ve done something
wrong. Go has no concept of cpu affinity so the practice has little value.
(Note that
Adding to a full buffered channel will not cause a crash. It can deadlock just
as the unbuffered can - but the deadlocks can be harder to diagnose.
> On Apr 13, 2022, at 3:40 AM, Zhaoxun Yan wrote:
>
>
> Since I found if inserting into a buffered channel could cause a crash if it
> is full
On Wed, 13 Apr 2022 01:40:22 -0700 (PDT)
Zhaoxun Yan wrote:
> Since I found if inserting into a buffered channel could cause a
> crash if it is full already
> ( now I only use unbuffered channels in work)
> https://groups.google.com/g/golang-nuts/c/U8lz6noKkuA
>
> package main
>
> var c = make(
Since I found if inserting into a buffered channel could cause a crash if
it is full already
( now I only use unbuffered channels in work)
https://groups.google.com/g/golang-nuts/c/U8lz6noKkuA
package main
var c = make(chan int, 1)
func main() {
c <- 1
c <- 2 //fatal error: all goro