From ee8149219e542f5a130472dbd35a2389cc2a9eb8 Mon Sep 17 00:00:00 2001
From: Mark McGranaghan
Date: Fri, 9 Feb 2018 14:47:28 -0800
Subject: [PATCH] Explain non-blocking sends
---
.../non-blocking-channel-operations.go | 5 ++++-
.../non-blocking-channel-operations.hash | 4 ++--
public/non-blocking-channel-operations | 7 +++++--
3 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/examples/non-blocking-channel-operations/non-blocking-channel-operations.go b/examples/non-blocking-channel-operations/non-blocking-channel-operations.go
index 24cd6ff..dfd0516 100644
--- a/examples/non-blocking-channel-operations/non-blocking-channel-operations.go
+++ b/examples/non-blocking-channel-operations/non-blocking-channel-operations.go
@@ -22,7 +22,10 @@ func main() {
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"
select {
case messages <- msg:
diff --git a/examples/non-blocking-channel-operations/non-blocking-channel-operations.hash b/examples/non-blocking-channel-operations/non-blocking-channel-operations.hash
index 3bca2a4..a9f03de 100644
--- a/examples/non-blocking-channel-operations/non-blocking-channel-operations.hash
+++ b/examples/non-blocking-channel-operations/non-blocking-channel-operations.hash
@@ -1,2 +1,2 @@
-119ced4df4f79795b163483b6abfd855e76ef577
-M972dltae2
+a6e0a8bb87153c7ed0de4996172f7ad5d89c6814
+n5ttmOsMrrJ
diff --git a/public/non-blocking-channel-operations b/public/non-blocking-channel-operations
index ba7aed6..2e2e713 100644
--- a/public/non-blocking-channel-operations
+++ b/public/non-blocking-channel-operations
@@ -42,7 +42,7 @@ non-blocking multi-way select
s.
-
+
@@ -98,7 +98,10 @@ it will immediately take the default case.
|
- 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.
|
|