mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
storage/backend: remove startc var
This makes start logic cleaner.
This commit is contained in:
parent
f04884f74d
commit
054fab84ee
@ -22,9 +22,8 @@ type backend struct {
|
|||||||
batchLimit int
|
batchLimit int
|
||||||
batchTx *batchTx
|
batchTx *batchTx
|
||||||
|
|
||||||
stopc chan struct{}
|
stopc chan struct{}
|
||||||
startc chan struct{}
|
donec chan struct{}
|
||||||
donec chan struct{}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(path string, d time.Duration, limit int) Backend {
|
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,
|
batchLimit: limit,
|
||||||
batchTx: &batchTx{},
|
batchTx: &batchTx{},
|
||||||
|
|
||||||
stopc: make(chan struct{}),
|
stopc: make(chan struct{}),
|
||||||
startc: make(chan struct{}),
|
donec: make(chan struct{}),
|
||||||
donec: make(chan struct{}),
|
|
||||||
}
|
}
|
||||||
b.batchTx.backend = b
|
b.batchTx.backend = b
|
||||||
|
b.batchTx.Commit()
|
||||||
go b.run()
|
go b.run()
|
||||||
<-b.startc
|
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,9 +71,6 @@ func (b *backend) Snapshot(w io.Writer) (n int64, err error) {
|
|||||||
func (b *backend) run() {
|
func (b *backend) run() {
|
||||||
defer close(b.donec)
|
defer close(b.donec)
|
||||||
|
|
||||||
b.batchTx.Commit()
|
|
||||||
b.startc <- struct{}{}
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-time.After(b.batchInterval):
|
case <-time.After(b.batchInterval):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user