aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2010-09-02 08:10:53 +1000
committerRob Pike <r@golang.org>2010-09-02 08:10:53 +1000
commit3d76135ee5b6084b1497b12421e3d3fe8b160a16 (patch)
tree1cc3bfb8893c10396b695d5c72dc808b99cb657c
parent426275d70236be0ac817ae8185c215e9fc4eb681 (diff)
downloadgo-3d76135ee5b6084b1497b12421e3d3fe8b160a16.tar.gz
go-3d76135ee5b6084b1497b12421e3d3fe8b160a16.zip
netchan: rather than 0, make -1 mean infinite, by analogy with strings.Split etc.
It's unlikely to affect any extant code, but I wanted to make this API change before digging in for a rewrite. R=rsc CC=golang-dev https://golang.org/cl/2112041
-rw-r--r--src/pkg/netchan/export.go5
-rw-r--r--src/pkg/netchan/import.go4
2 files changed, 5 insertions, 4 deletions
diff --git a/src/pkg/netchan/export.go b/src/pkg/netchan/export.go
index a16714ba23..3142eebf73 100644
--- a/src/pkg/netchan/export.go
+++ b/src/pkg/netchan/export.go
@@ -154,8 +154,9 @@ func (client *expClient) serveRecv(hdr header, count int) {
client.sendError(&hdr, err.String())
break
}
- if count > 0 {
- if count--; count == 0 {
+ // Negative count means run forever.
+ if count >= 0 {
+ if count--; count <= 0 {
break
}
}
diff --git a/src/pkg/netchan/import.go b/src/pkg/netchan/import.go
index 244a83c5bc..1effbaef4a 100644
--- a/src/pkg/netchan/import.go
+++ b/src/pkg/netchan/import.go
@@ -114,14 +114,14 @@ func (imp *Importer) run() {
}
// Import imports a channel of the given type and specified direction.
-// It is equivalent to ImportNValues with a count of 0, meaning unbounded.
+// It is equivalent to ImportNValues with a count of -1, meaning unbounded.
func (imp *Importer) Import(name string, chT interface{}, dir Dir) os.Error {
return imp.ImportNValues(name, chT, dir, 0)
}
// ImportNValues imports a channel of the given type and specified direction
// and then receives or transmits up to n values on that channel. A value of
-// n==0 implies an unbounded number of values. The channel to be bound to
+// n==-1 implies an unbounded number of values. The channel to be bound to
// the remote site's channel is provided in the call and may be of arbitrary
// channel type.
// Despite the literal signature, the effective signature is