TaskManager refactor: avoid using Simulator::Schedule()
diff --git a/model/dce.cc b/model/dce.cc
--- a/model/dce.cc
+++ b/model/dce.cc
@@ -502,8 +502,9 @@
{
if (!process->itimerInterval.IsZero ())
{
- process->itimer = Simulator::Schedule (process->itimerInterval,
- &Itimer, process);
+ process->itimer = Simulator::ScheduleWithContext (Simulator::GetContext (),
+ process->itimerInterval,
+ &Itimer, process);
}
// wakeup one thread
UtilsSendSignal (process, SIGALRM);
@@ -551,8 +552,9 @@
{
return 0;
}
- current->process->itimer = Simulator::Schedule (UtilsTimevalToTime (value->it_value),
- &Itimer, current->process);
+ current->process->itimer = Simulator::ScheduleWithContext (Simulator::GetContext (),
+ UtilsTimevalToTime (value->it_value),
+ &Itimer, current->process);
return 0;
}
char * dce_getcwd (char *buf, size_t size)
diff --git a/model/linux-socket-fd-factory.cc b/model/linux-socket-fd-factory.cc
--- a/model/linux-socket-fd-factory.cc
+++ b/model/linux-socket-fd-factory.cc
@@ -198,9 +198,9 @@
{
LinuxSocketFdFactory *self = (LinuxSocketFdFactory *)kernel;
Ptr<EventIdHolder> ev = Create<EventIdHolder> ();
- EventId event = Simulator::Schedule (NanoSeconds (ns),
- &LinuxSocketFdFactory::EventTrampoline,
- self, fn, context, pre_fn, ev);
+ EventId event = Simulator::ScheduleWithContext (Simulator::GetContext (), NanoSeconds (ns),
+ &LinuxSocketFdFactory::EventTrampoline,
+ self, fn, context, pre_fn, ev);
ev->id = event;
return &ev->id;
}
diff --git a/model/task-manager.cc b/model/task-manager.cc
--- a/model/task-manager.cc
+++ b/model/task-manager.cc
@@ -9,6 +9,7 @@
#include "ns3/simulator.h"
#include "ns3/node.h"
#include "ns3/node-list.h"
+#include "ns3/event-id.h"
#include "dce-manager.h"
#include "dce-stdio.h"
#include "process.h"
@@ -295,7 +296,8 @@
m_scheduler->Enqueue (task);
if (!m_nextSchedule.IsRunning ())
{
- m_nextSchedule = Simulator::ScheduleNow (&TaskManager::Schedule, this);
+ m_nextSchedule = Simulator::ScheduleWithContext (Simulator::GetContext (), Seconds (0.0),
+ &TaskManager::Schedule, this);
}
}
@@ -321,7 +323,9 @@
current->m_state = Task::BLOCKED;
if (!timeout.IsZero ())
{
- current->m_waitTimer = Simulator::Schedule (timeout, &TaskManager::EndWait, this, current);
+ current->m_waitTimer = Simulator::ScheduleWithContext (Simulator::GetContext (), timeout,
+ &TaskManager::EndWait, this, current);
+
}
Schedule ();
current->m_waitTimer.Cancel ();
@@ -355,7 +359,8 @@
m_deadTasks.push_back (current);
if (!m_nextGc.IsRunning ())
{
- m_nextGc = Simulator::ScheduleNow (&TaskManager::GarbageCollectDeadTasks, this);
+ m_nextGc = Simulator::ScheduleWithContext (Simulator::GetContext (), Simulator::Now (),
+ &TaskManager::GarbageCollectDeadTasks, this);
}
Schedule ();
}
@@ -417,7 +422,9 @@
{
// but before leaving, we check if we have further processes active, and,
// if so, make sure we will schedule them later.
- Simulator::Schedule (delay, &TaskManager::Schedule, this);
+ Thread* thread = (Thread *)next->GetContext ();
+ Simulator::ScheduleWithContext (Simulator::GetContext (), delay,
+ &TaskManager::Schedule, this);
}
struct Fiber *fiber = m_current->m_fiber;
if (m_current->m_switchNotifier != 0)
diff --git a/model/unix-timer-fd.cc b/model/unix-timer-fd.cc
--- a/model/unix-timer-fd.cc
+++ b/model/unix-timer-fd.cc
@@ -207,9 +207,10 @@
{
if (!m_period.IsZero ())
{
- m_timer = Simulator::Schedule (m_period,
- &UnixTimerFd::TimerExpired,
- this);
+ m_timer = Simulator::ScheduleWithContext (Simulator::GetContext (),
+ m_period,
+ &UnixTimerFd::TimerExpired,
+ this);
}
m_skipped++;
if (m_waiter != 0)
@@ -233,9 +234,10 @@
Time initial = UtilsTimespecToTime (new_value->it_value);
if (!initial.IsZero ())
{
- m_timer = Simulator::Schedule (initial,
- &UnixTimerFd::TimerExpired,
- this);
+ m_timer = Simulator::ScheduleWithContext (Simulator::GetContext (),
+ initial,
+ &UnixTimerFd::TimerExpired,
+ this);
}
return 0;
}