From 055e992766ece0520e56bcff1fbabe2c211a756c Mon Sep 17 00:00:00 2001 From: free will <2647778488@qq.com> Date: Thu, 19 May 2022 11:52:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E8=B7=AF=E7=94=B1=E8=A1=A8?= =?UTF-8?q?=E4=B8=AD=E5=AF=B9=E4=BA=8E=E5=B0=9A=E6=9C=AA=E8=AE=A1=E5=88=92?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E4=BA=8B=E4=BB=B6=E7=9A=84=E5=A4=84=E7=90=86?= =?UTF-8?q?ScheduleRoutingTableCalculation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- route/RoutingTable.go | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/route/RoutingTable.go b/route/RoutingTable.go index aacee96..75d908d 100644 --- a/route/RoutingTable.go +++ b/route/RoutingTable.go @@ -26,11 +26,13 @@ type RoutingTable struct { lsdb *lsdb.Lsdb // 配置参数 mlsrConfig *common.MlsrConfig + // 任务调度器 + scheduler *lsdb.MlsrScheduler // 路由条目列表 rTable []*RoutingTableEntry // 路由计算间隔时间 - m_routingCalcInterval *time.Duration + m_routingCalcInterval time.Duration // 路由表是否正在计算 m_isRoutingTableCalculating bool // 是否已经安排了路由计算 @@ -42,6 +44,12 @@ type RoutingTable struct { m_hyperbolicState uint32 } +func (t *RoutingTable) Init() { + // 初始化任务调度器 + t.scheduler = new(lsdb.MlsrScheduler) + t.scheduler.Init() +} + // // Calculate // @Description: 计算网络中每个路由器的下一个跃点列表。 @@ -85,10 +93,16 @@ func (t *RoutingTable) FindRoutingTableEntry(destRouter *component.Identifier) * // @Description: 仅当尚未计划计算事件时,才在事件计划程序中计划计算事件。 // @receiver t // -func (t *RoutingTable) ScheduleRoutingTableCalculation() { +func (t *RoutingTable) ScheduleRoutingTableCalculation() error { if !t.m_isRouteCalculationScheduled { - + common2.LogFatal("Scheduling routing table calculation in ", t.m_routingCalcInterval) + err := t.scheduler.ScheduleTaskAfterDuration(t.m_routingCalcInterval, t.Calculate) + if err != nil { + return err + } + t.m_isRouteCalculationScheduled = true } + return nil } //