storage/backend: remove startc var

This makes start logic cleaner.
This commit is contained in:
Yicheng Qin 2015-08-27 22:59:14 -07:00
parent f04884f74d
commit 054fab84ee

View File

@ -23,7 +23,6 @@ type backend struct {
batchTx *batchTx
stopc chan struct{}
startc chan struct{}
donec chan struct{}
}
@ -41,12 +40,11 @@ func New(path string, d time.Duration, limit int) Backend {
batchTx: &batchTx{},
stopc: make(chan struct{}),
startc: 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):