From 4f5774be5b0917102bd11b9bba9c2ba369beb1bd Mon Sep 17 00:00:00 2001 From: "menglei.zhang" Date: Mon, 3 Nov 2025 12:10:24 -0800 Subject: [PATCH] Initialize m_savedNodeList during Partition --- src/mtp/model/multithreaded-simulator-impl.cc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/mtp/model/multithreaded-simulator-impl.cc b/src/mtp/model/multithreaded-simulator-impl.cc index 37a82b8c3..b6406a25b 100644 --- a/src/mtp/model/multithreaded-simulator-impl.cc +++ b/src/mtp/model/multithreaded-simulator-impl.cc @@ -138,12 +138,10 @@ MultithreadedSimulatorImpl::ScheduleWithContext(uint32_t context, EventImpl* event) { NS_LOG_FUNCTION(this << context << delay.GetTimeStep() << event); - if (m_savedNodeList.GetN() <= context) - { - m_savedNodeList = NodeContainer::GetGlobal(); - } - LogicalProcess* remote = MtpInterface::GetSystem(m_savedNodeList.Get(context)->GetSystemId()); - MtpInterface::GetSystem()->ScheduleWithContext(remote, context, delay, event); + const bool useSaved = (context < m_savedNodeList.GetN()); + Ptr node = useSaved ? m_savedNodeList.Get(context) : NodeList::GetNode(context); + LogicalProcess* remote = MtpInterface::GetSystem(node->GetSystemId()); + remote->ScheduleWithContext(remote, context, delay, event); } EventId @@ -303,6 +301,7 @@ MultithreadedSimulatorImpl::Partition() NS_LOG_FUNCTION(this); uint32_t systemId = 0; const NodeContainer nodes = NodeContainer::GetGlobal(); + m_savedNodeList = NodeContainer::GetGlobal(); bool* visited = new bool[nodes.GetN()]{false}; std::queue> q;