Skip to content

Commit

Permalink
bundler: rename Close to Stop
Browse files Browse the repository at this point in the history
The name Close should be used for methods that return error, and Stop
for methods that don't.

Change-Id: I545770da48605db307d61713b2bbdf9144f005a2
Reviewed-on: https://code-review.googlesource.com/9839
Reviewed-by: Michael McGreevy <mcgreevy@golang.org>
  • Loading branch information
jba committed Dec 13, 2016
1 parent d48d03b commit 6ae94d3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions support/bundler/bundler.go
Expand Up @@ -87,7 +87,7 @@ type bundle struct {
}

// NewBundler creates a new Bundler. When you are finished with a Bundler, call
// its Close method.
// its Stop method.
//
// itemExample is a value of the type that will be bundled. For example, if you
// want to create bundles of *Entry, you could pass &Entry{} for itemExample.
Expand Down Expand Up @@ -177,11 +177,11 @@ func (b *Bundler) Flush() {
<-calledc
}

// Close calls Flush, then shuts down the Bundler. Close should always be
// Stop calls Flush, then shuts down the Bundler. Stop should always be
// called on a Bundler when it is no longer needed. You must wait for all calls
// to Add to complete before calling Close. Calling Add concurrently with Close
// to Add to complete before calling Stop. Calling Add concurrently with Stop
// may result in the added items being ignored.
func (b *Bundler) Close() {
func (b *Bundler) Stop() {
b.Flush()
b.mu.Lock()
b.timer.Stop()
Expand Down
6 changes: 3 additions & 3 deletions support/bundler/bundler_test.go
Expand Up @@ -33,7 +33,7 @@ func TestBundlerCount1(t *testing.T) {
t.Fatal(err)
}
}
b.Close()
b.Stop()
got := handler.bundles()
want := [][]int{{0}, {1}, {2}}
if !reflect.DeepEqual(got, want) {
Expand Down Expand Up @@ -95,7 +95,7 @@ func TestBundlerByteThreshold(t *testing.T) {
add(5, 2)
// Passed byte threshold, but not limit: bundle = 3, 4, 5
add(6, 1)
b.Close()
b.Stop()
bgot := handler.bundles()
bwant := [][]int{{1, 2}, {3, 4, 5}, {6}}
if !reflect.DeepEqual(bgot, bwant) {
Expand Down Expand Up @@ -128,7 +128,7 @@ func TestBundlerLimit(t *testing.T) {
// Exceeded byte limit: bundle = 3, 4
add(6, 2)
// Exceeded byte limit: bundle = 5
b.Close()
b.Stop()
bgot := handler.bundles()
bwant := [][]int{{1, 2}, {3, 4}, {5}, {6}}
if !reflect.DeepEqual(bgot, bwant) {
Expand Down

0 comments on commit 6ae94d3

Please sign in to comment.