mobility: cancel update event when the model is destroyed
This commit is contained in:
@@ -103,6 +103,11 @@ GaussMarkovMobilityModel::GaussMarkovMobilityModel()
|
||||
m_helper.Unpause();
|
||||
}
|
||||
|
||||
GaussMarkovMobilityModel::~GaussMarkovMobilityModel()
|
||||
{
|
||||
m_event.Cancel();
|
||||
}
|
||||
|
||||
void
|
||||
GaussMarkovMobilityModel::Start()
|
||||
{
|
||||
|
||||
@@ -87,6 +87,7 @@ class GaussMarkovMobilityModel : public MobilityModel
|
||||
*/
|
||||
static TypeId GetTypeId();
|
||||
GaussMarkovMobilityModel();
|
||||
~GaussMarkovMobilityModel() override;
|
||||
|
||||
private:
|
||||
/**
|
||||
|
||||
@@ -64,6 +64,11 @@ RandomDirection2dMobilityModel::RandomDirection2dMobilityModel()
|
||||
m_direction = CreateObject<UniformRandomVariable>();
|
||||
}
|
||||
|
||||
RandomDirection2dMobilityModel::~RandomDirection2dMobilityModel()
|
||||
{
|
||||
m_event.Cancel();
|
||||
}
|
||||
|
||||
void
|
||||
RandomDirection2dMobilityModel::DoDispose()
|
||||
{
|
||||
|
||||
@@ -51,6 +51,7 @@ class RandomDirection2dMobilityModel : public MobilityModel
|
||||
*/
|
||||
static TypeId GetTypeId();
|
||||
RandomDirection2dMobilityModel();
|
||||
~RandomDirection2dMobilityModel() override;
|
||||
|
||||
private:
|
||||
/**
|
||||
|
||||
@@ -80,6 +80,11 @@ RandomWalk2dMobilityModel::GetTypeId()
|
||||
return tid;
|
||||
}
|
||||
|
||||
RandomWalk2dMobilityModel::~RandomWalk2dMobilityModel()
|
||||
{
|
||||
m_event.Cancel();
|
||||
}
|
||||
|
||||
void
|
||||
RandomWalk2dMobilityModel::DoInitialize()
|
||||
{
|
||||
|
||||
@@ -57,6 +57,8 @@ class RandomWalk2dMobilityModel : public MobilityModel
|
||||
*/
|
||||
static TypeId GetTypeId();
|
||||
|
||||
~RandomWalk2dMobilityModel() override;
|
||||
|
||||
/** An enum representing the different working modes of this module. */
|
||||
enum Mode
|
||||
{
|
||||
|
||||
@@ -59,6 +59,11 @@ RandomWaypointMobilityModel::GetTypeId()
|
||||
return tid;
|
||||
}
|
||||
|
||||
RandomWaypointMobilityModel::~RandomWaypointMobilityModel()
|
||||
{
|
||||
m_event.Cancel();
|
||||
}
|
||||
|
||||
void
|
||||
RandomWaypointMobilityModel::BeginWalk()
|
||||
{
|
||||
|
||||
@@ -59,6 +59,8 @@ class RandomWaypointMobilityModel : public MobilityModel
|
||||
*/
|
||||
static TypeId GetTypeId();
|
||||
|
||||
~RandomWaypointMobilityModel() override;
|
||||
|
||||
protected:
|
||||
void DoInitialize() override;
|
||||
|
||||
|
||||
@@ -101,6 +101,11 @@ SteadyStateRandomWaypointMobilityModel::SteadyStateRandomWaypointMobilityModel()
|
||||
m_position = CreateObject<RandomBoxPositionAllocator>();
|
||||
}
|
||||
|
||||
SteadyStateRandomWaypointMobilityModel::~SteadyStateRandomWaypointMobilityModel()
|
||||
{
|
||||
m_event.Cancel();
|
||||
}
|
||||
|
||||
void
|
||||
SteadyStateRandomWaypointMobilityModel::DoInitialize()
|
||||
{
|
||||
|
||||
@@ -62,6 +62,7 @@ class SteadyStateRandomWaypointMobilityModel : public MobilityModel
|
||||
*/
|
||||
static TypeId GetTypeId();
|
||||
SteadyStateRandomWaypointMobilityModel();
|
||||
~SteadyStateRandomWaypointMobilityModel() override;
|
||||
|
||||
protected:
|
||||
void DoInitialize() override;
|
||||
|
||||
@@ -77,6 +77,7 @@ WaypointMobilityModel::WaypointMobilityModel()
|
||||
|
||||
WaypointMobilityModel::~WaypointMobilityModel()
|
||||
{
|
||||
m_event.Cancel();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -102,7 +103,9 @@ WaypointMobilityModel::AddWaypoint(const Waypoint& waypoint)
|
||||
|
||||
if (!m_lazyNotify)
|
||||
{
|
||||
Simulator::Schedule(waypoint.time - Simulator::Now(), &WaypointMobilityModel::Update, this);
|
||||
m_event = Simulator::Schedule(waypoint.time - Simulator::Now(),
|
||||
&WaypointMobilityModel::Update,
|
||||
this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -192,6 +192,10 @@ class WaypointMobilityModel : public MobilityModel
|
||||
* \brief The current velocity vector
|
||||
*/
|
||||
mutable Vector m_velocity;
|
||||
/**
|
||||
* \brief Update event
|
||||
*/
|
||||
EventId m_event;
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
Reference in New Issue
Block a user