mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-05 21:20:06 +00:00
⚡️ refactor: 将排序的服务器列表的锁拆分出来
This commit is contained in:
@@ -31,7 +31,7 @@ func DispatchTask(duration time.Duration) {
|
||||
var tasks []model.Monitor
|
||||
var hasAliveAgent bool
|
||||
dao.DB.Find(&tasks)
|
||||
dao.ServerLock.RLock()
|
||||
dao.SortedServerLock.RLock()
|
||||
startedAt := time.Now()
|
||||
for i := 0; i < len(tasks); i++ {
|
||||
if index >= uint64(len(dao.SortedServerList)) {
|
||||
@@ -50,7 +50,7 @@ func DispatchTask(duration time.Duration) {
|
||||
dao.SortedServerList[index].TaskStream.Send(tasks[i].PB())
|
||||
index++
|
||||
}
|
||||
dao.ServerLock.RUnlock()
|
||||
dao.SortedServerLock.RUnlock()
|
||||
time.Sleep(time.Until(startedAt.Add(duration)))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user