mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 14:15:06 +03:00
move periodic switch maintenance into the router instead of its own goroutine
This commit is contained in:
parent
5dc0cb5544
commit
3b783fbf97
4 changed files with 2 additions and 23 deletions
|
@ -170,26 +170,13 @@ func (t *switchTable) init(core *Core, key sigPubKey) {
|
|||
t.drop = make(map[sigPubKey]int64)
|
||||
}
|
||||
|
||||
func (t *switchTable) start() error {
|
||||
doTicker := func() {
|
||||
ticker := time.NewTicker(time.Second)
|
||||
defer ticker.Stop()
|
||||
for {
|
||||
<-ticker.C
|
||||
t.Tick()
|
||||
}
|
||||
}
|
||||
go doTicker()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *switchTable) getLocator() switchLocator {
|
||||
t.mutex.RLock()
|
||||
defer t.mutex.RUnlock()
|
||||
return t.data.locator.clone()
|
||||
}
|
||||
|
||||
func (t *switchTable) Tick() {
|
||||
func (t *switchTable) doMaintenance() {
|
||||
// Periodic maintenance work to keep things internally consistent
|
||||
t.mutex.Lock() // Write lock
|
||||
defer t.mutex.Unlock() // Release lock when we're done
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue