Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(454)

Unified Diff: src/pkg/netchan/common.go

Issue 4079053: code review 4079053: replace non-blocking send, receive syntax with select (Closed)
Patch Set: code review 4079053: replace non-blocking send, receive syntax with select Created 14 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pkg/net/server_test.go ('k') | src/pkg/netchan/import.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pkg/netchan/common.go
===================================================================
--- a/src/pkg/netchan/common.go
+++ b/src/pkg/netchan/common.go
@@ -256,7 +256,10 @@
nch.sendCh = make(chan reflect.Value, nch.size)
go nch.sender()
}
- if ok := nch.sendCh <- val; !ok {
+ select {
+ case nch.sendCh <- val:
+ // ok
+ default:
// TODO: should this be more resilient?
panic("netchan: remote sender sent more values than allowed")
}
@@ -318,8 +321,11 @@
if nch.dir != Send {
panic("recv on wrong direction of channel")
}
- if ok := nch.ackCh <- true; !ok {
+ select {
+ case nch.ackCh <- true:
+ // ok
+ default:
+ // TODO: should this be more resilient?
panic("netchan: remote receiver sent too many acks")
- // TODO: should this be more resilient?
}
}
« no previous file with comments | « src/pkg/net/server_test.go ('k') | src/pkg/netchan/import.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b