全面解析 Go 語言 Channel:面試必備知識點

一、channel 的整體結構圖

1、channel 結構圖

type hchan struct {
    buf      unsafe.Pointer // points to an array of dataqsiz elements
    sendx    uint   // send index
    recvx    uint   // receive index
    recvq    waitq  // list of recv waiters
    sendq    waitq  // list of send waiters
    lock mutex
}

**2、創建 channel
**

3、channel 中隊列如何實現

4、channel 緩存滿發生什麼

本文由 Readfog 進行 AMP 轉碼,版權歸原作者所有。
來源https://mp.weixin.qq.com/s/JLhN9azPrqLtv3qLCc9VKg