Browse Source

storage/backend: remove startc var

This makes start logic cleaner.
Yicheng Qin 10 years ago
parent
commit
054fab84ee
1 changed files with 5 additions and 10 deletions
  1. 5 10
      storage/backend/backend.go

+ 5 - 10
storage/backend/backend.go

@@ -22,9 +22,8 @@ type backend struct {
 	batchLimit    int
 	batchTx       *batchTx
 
-	stopc  chan struct{}
-	startc chan struct{}
-	donec  chan struct{}
+	stopc chan struct{}
+	donec chan struct{}
 }
 
 func New(path string, d time.Duration, limit int) Backend {
@@ -40,13 +39,12 @@ func New(path string, d time.Duration, limit int) Backend {
 		batchLimit:    limit,
 		batchTx:       &batchTx{},
 
-		stopc:  make(chan struct{}),
-		startc: make(chan struct{}),
-		donec:  make(chan struct{}),
+		stopc: make(chan struct{}),
+		donec: make(chan struct{}),
 	}
 	b.batchTx.backend = b
+	b.batchTx.Commit()
 	go b.run()
-	<-b.startc
 	return b
 }
 
@@ -73,9 +71,6 @@ func (b *backend) Snapshot(w io.Writer) (n int64, err error) {
 func (b *backend) run() {
 	defer close(b.donec)
 
-	b.batchTx.Commit()
-	b.startc <- struct{}{}
-
 	for {
 		select {
 		case <-time.After(b.batchInterval):