Browse Source

Move flow.cur out of test file. Might use it in ResponseWriter.

Brad Fitzpatrick 11 years ago
parent
commit
1f430e1246
2 changed files with 10 additions and 6 deletions
  1. 10 0
      flow.go
  2. 0 6
      flow_test.go

+ 10 - 0
flow.go

@@ -22,6 +22,16 @@ func newFlow(n int32) *flow {
 	}
 }
 
+// cur returns the current number of bytes allow to write.  Obviously
+// it's not safe to call this and assume acquiring that number of
+// bytes from the acquire method won't be block in the presence of
+// concurrent acquisitions.
+func (f *flow) cur() int32 {
+	f.c.L.Lock()
+	defer f.c.L.Unlock()
+	return f.size
+}
+
 // acquire decrements the flow control window by n bytes, blocking
 // until they're available in the window.
 // The return value is only interesting for tests.

+ 0 - 6
flow_test.go

@@ -10,12 +10,6 @@ import (
 	"time"
 )
 
-func (f *flow) cur() int32 {
-	f.c.L.Lock()
-	defer f.c.L.Unlock()
-	return f.size
-}
-
 func TestFlow(t *testing.T) {
 	f := newFlow(10)
 	if got, want := f.cur(), int32(10); got != want {