2017 Feb 2017 Feb

关于 Golang 内存模型

最近开始学习 Go 语言,在看到其 内存模型 的时候一度懵逼了,主要是碰到关于信道的其中两句概念整理以为冲突了,先整理自己的理解如下。

原文

A send on a channel happens before the corresponding receive from that channel completes.

A receive from an unbuffered channel happens before the send on that channel completes.

从字面意思来看:

  1. 发送到信道的动作发生在对应的接收动作完成之前(这个是针对带缓冲区域和不带缓冲区域的)
  2. 针对不带缓冲的信道,从信道接收的动作要发生在发送数据到信道动作完成之前…
/*This is placeholder text. This is placeholder text. This is placeholder text. This is placeholder text. |bitbili.net| This is placeholder text. This is placeholder text. This is placeholder text. This is placeholder text.*/