Merge pull request #194 from mmcgrana/explain-nonblocking-send
Explain non-blocking sends
This commit is contained in:
commit
33970ecff2
@ -22,7 +22,10 @@ func main() {
|
|||||||
fmt.Println("no message received")
|
fmt.Println("no message received")
|
||||||
}
|
}
|
||||||
|
|
||||||
// A non-blocking send works similarly.
|
// A non-blocking send works similarly. Here `msg`
|
||||||
|
// cannot be sent to the `messages` channel, because
|
||||||
|
// the channel has no buffer and there is no receiver.
|
||||||
|
// Therefore the `default` case is selected.
|
||||||
msg := "hi"
|
msg := "hi"
|
||||||
select {
|
select {
|
||||||
case messages <- msg:
|
case messages <- msg:
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
119ced4df4f79795b163483b6abfd855e76ef577
|
a6e0a8bb87153c7ed0de4996172f7ad5d89c6814
|
||||||
M972dltae2
|
n5ttmOsMrrJ
|
||||||
|
@ -42,7 +42,7 @@ non-blocking multi-way <code>select</code>s.</p>
|
|||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td class="code leading">
|
<td class="code leading">
|
||||||
<a href="http://play.golang.org/p/M972dltae2"><img title="Run code" src="play.png" class="run" /></a>
|
<a href="http://play.golang.org/p/n5ttmOsMrrJ"><img title="Run code" src="play.png" class="run" /></a>
|
||||||
<div class="highlight"><pre><span class="kn">package</span> <span class="nx">main</span>
|
<div class="highlight"><pre><span class="kn">package</span> <span class="nx">main</span>
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
@ -98,7 +98,10 @@ it will immediately take the <code>default</code> case.</p>
|
|||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="docs">
|
<td class="docs">
|
||||||
<p>A non-blocking send works similarly.</p>
|
<p>A non-blocking send works similarly. Here <code>msg</code>
|
||||||
|
cannot be sent to the <code>messages</code> channel, because
|
||||||
|
the channel has no buffer and there is no receiver.
|
||||||
|
Therefore the <code>default</code> case is selected.</p>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td class="code leading">
|
<td class="code leading">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user