Browse Source

rm needless lock on responses

rm duplicate mark check in tests
Dan Frank 12 years ago
parent
commit
0ef057a3da
3 changed files with 2 additions and 13 deletions
  1. 2 4
      epsilon_greedy.go
  2. 0 7
      hostpool.go
  3. 0 2
      hostpool_test.go

+ 2 - 4
epsilon_greedy.go

@@ -13,10 +13,8 @@ type epsilonHostPoolResponse struct {
 }
 
 func (r *epsilonHostPoolResponse) Mark(err error) {
-	r.Do(func() {
-		r.ended = time.Now()
-		doMark(err, r)
-	})
+	r.ended = time.Now()
+	r.standardHostPoolResponse.Mark(err)
 
 }
 

+ 0 - 7
hostpool.go

@@ -28,7 +28,6 @@ type HostPoolResponse interface {
 
 type standardHostPoolResponse struct {
 	host string
-	sync.Once
 	pool HostPool
 }
 
@@ -94,12 +93,6 @@ func (r *standardHostPoolResponse) hostPool() HostPool {
 }
 
 func (r *standardHostPoolResponse) Mark(err error) {
-	r.Do(func() {
-		doMark(err, r)
-	})
-}
-
-func doMark(err error, r HostPoolResponse) {
 	if err == nil {
 		r.hostPool().markSuccess(r)
 	} else {

+ 0 - 2
hostpool_test.go

@@ -32,8 +32,6 @@ func TestHostPool(t *testing.T) {
 	respC.Mark(nil)
 	// get again, and verify that it's still c
 	assert.Equal(t, p.Get().Host(), "c")
-	// now try to mark b as success; should fail because already marked
-	respB.Mark(nil)
 	assert.Equal(t, p.Get().Host(), "c") // would be b if it were not dead
 	// now restore a
 	respA = &standardHostPoolResponse{host: "a", pool: p}