mirror of
https://github.com/restic/restic.git
synced 2024-12-23 16:26:11 +00:00
Don't separately allocate sync.{Mutex,Once} if not necessary
Separate allocation of synchronization devices suggests they're shared between objects, but they're not.
This commit is contained in:
parent
bb4b3481a6
commit
c2f3eee5af
2 changed files with 3 additions and 5 deletions
|
@ -21,7 +21,7 @@ type LocalVss struct {
|
||||||
FS
|
FS
|
||||||
snapshots map[string]VssSnapshot
|
snapshots map[string]VssSnapshot
|
||||||
failedSnapshots map[string]struct{}
|
failedSnapshots map[string]struct{}
|
||||||
mutex *sync.RWMutex
|
mutex sync.RWMutex
|
||||||
msgError ErrorHandler
|
msgError ErrorHandler
|
||||||
msgMessage MessageHandler
|
msgMessage MessageHandler
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,6 @@ func NewLocalVss(msgError ErrorHandler, msgMessage MessageHandler) *LocalVss {
|
||||||
FS: Local{},
|
FS: Local{},
|
||||||
snapshots: make(map[string]VssSnapshot),
|
snapshots: make(map[string]VssSnapshot),
|
||||||
failedSnapshots: make(map[string]struct{}),
|
failedSnapshots: make(map[string]struct{}),
|
||||||
mutex: &sync.RWMutex{},
|
|
||||||
msgError: msgError,
|
msgError: msgError,
|
||||||
msgMessage: msgMessage,
|
msgMessage: msgMessage,
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ type Progress struct {
|
||||||
start time.Time
|
start time.Time
|
||||||
c *time.Ticker
|
c *time.Ticker
|
||||||
cancel chan struct{}
|
cancel chan struct{}
|
||||||
o *sync.Once
|
once sync.Once
|
||||||
d time.Duration
|
d time.Duration
|
||||||
lastUpdate time.Time
|
lastUpdate time.Time
|
||||||
|
|
||||||
|
@ -79,7 +79,6 @@ func (p *Progress) Start() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
p.o = &sync.Once{}
|
|
||||||
p.cancel = make(chan struct{})
|
p.cancel = make(chan struct{})
|
||||||
p.running = true
|
p.running = true
|
||||||
p.Reset()
|
p.Reset()
|
||||||
|
@ -187,7 +186,7 @@ func (p *Progress) Done() {
|
||||||
}
|
}
|
||||||
|
|
||||||
p.running = false
|
p.running = false
|
||||||
p.o.Do(func() {
|
p.once.Do(func() {
|
||||||
close(p.cancel)
|
close(p.cancel)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue