make sure that Simulator::Cancel deals correctly with events which were already scheduled
parent
6e03b80cd0
commit
b7ad24cea9
|
@ -20,6 +20,7 @@
|
|||
*/
|
||||
#include "event-id.h"
|
||||
#include "simulator.h"
|
||||
#include "event-impl.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
|
@ -37,7 +38,11 @@ EventId::EventId (EventImpl *impl, uint64_t ns, uint32_t uid)
|
|||
void
|
||||
EventId::Cancel (void)
|
||||
{
|
||||
Simulator::Cancel (*this);
|
||||
if (!IsExpired ())
|
||||
{
|
||||
m_eventImpl->Cancel ();
|
||||
m_eventImpl = 0;
|
||||
}
|
||||
}
|
||||
bool
|
||||
EventId::IsExpired (void)
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
void ScheduleNow (EventImpl *event);
|
||||
void ScheduleDestroy (EventImpl *event);
|
||||
void Remove (EventId ev);
|
||||
void Cancel (EventId ev);
|
||||
void Cancel (EventId &ev);
|
||||
bool IsExpired (EventId ev);
|
||||
void Run (void);
|
||||
Time Now (void) const;
|
||||
|
@ -258,10 +258,9 @@ SimulatorPrivate::Remove (EventId ev)
|
|||
}
|
||||
|
||||
void
|
||||
SimulatorPrivate::Cancel (EventId id)
|
||||
SimulatorPrivate::Cancel (EventId &id)
|
||||
{
|
||||
EventImpl *ev = id.GetEventImpl ();
|
||||
ev->Cancel ();
|
||||
id.Cancel ();
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -453,7 +452,7 @@ Simulator::Remove (EventId ev)
|
|||
}
|
||||
|
||||
void
|
||||
Simulator::Cancel (EventId ev)
|
||||
Simulator::Cancel (EventId &ev)
|
||||
{
|
||||
return GetPriv ()->Cancel (ev);
|
||||
}
|
||||
|
|
|
@ -485,7 +485,7 @@ public:
|
|||
/**
|
||||
* Remove an event from the event list.
|
||||
* This method has the same visible effect as the
|
||||
* ns3::Simulator::cancel method or the ns3::EventId::cancel method
|
||||
* ns3::EventId::Cancel method
|
||||
* but its algorithmic complexity is much higher: it has often
|
||||
* O(log(n)) complexity, sometimes O(n), sometimes worse.
|
||||
* Note that it is not possible to remove events which were scheduled
|
||||
|
@ -506,7 +506,7 @@ public:
|
|||
*
|
||||
* @param id the event to cancel
|
||||
*/
|
||||
static void Cancel (EventId id);
|
||||
static void Cancel (EventId &id);
|
||||
/**
|
||||
* This method has O(1) complexity.
|
||||
* Note that it is not possible to test for the expiration of
|
||||
|
|
Loading…
Reference in New Issue