merge in raj's dispose early work

Mathieu Lacage 2007-05-02 09:10:19 +02:00
parent 4206fd3bce
commit 9eaf9191d8
8 changed files with 36 additions and 0 deletions

View File

@ -106,6 +106,16 @@ PointToPointNetDevice::PointToPointNetDevice (const PointToPointNetDevice& nd)
}
void PointToPointNetDevice::Dispose()
{
if (m_channel != 0)
{
m_channel->Unref ();
m_channel = 0;
}
NetDevice::Dispose ();
}
//
// Assignment operator for PointToPointNetDevice.
//
@ -357,6 +367,7 @@ PointToPointNetDevice::GetQueue(void) const
Channel*
PointToPointNetDevice::DoGetChannel(void) const
{
m_channel->Ref();
return m_channel;
}

View File

@ -96,6 +96,10 @@ public:
* This is the destructor for the PointToPointNetDevice.
*/
virtual ~PointToPointNetDevice();
/**
*Dispose method for refcounting
*/
virtual void Dispose();
/**
* Assignment Operator for a PointToPointNetDevice
*

View File

@ -106,6 +106,12 @@ InternetNode::CreateTraceResolver (TraceContext const &context)
return resolver;
}
void InternetNode::Dispose()
{
for(uint32_t i=0;i<GetNDevices();++i)
GetDevice(i)->Dispose();
}
ApplicationList*
InternetNode::GetApplicationList() const

View File

@ -47,6 +47,7 @@ public:
virtual ~InternetNode ();
virtual InternetNode* Copy() const;
virtual TraceResolver *CreateTraceResolver (TraceContext const &context);
virtual void Dispose();
// Capability access
virtual ApplicationList* GetApplicationList() const;
virtual L3Demux* GetL3Demux() const;

View File

@ -25,6 +25,7 @@
#include "net-device.h"
#include "llc-snap-header.h"
#include "node.h"
#include "ns3/channel.h"
namespace ns3 {
@ -225,4 +226,9 @@ NetDevice::SetReceiveCallback (Callback<bool,NetDevice *,const Packet &,uint16_t
m_receiveCallback = cb;
}
void
NetDevice::Dispose()
{
}
}; // namespace ns3

View File

@ -155,6 +155,8 @@ class NetDevice {
bool NeedsArp (void) const;
void SetReceiveCallback (Callback<bool,NetDevice *,const Packet &,uint16_t> cb);
virtual void Dispose();
protected:
/**

View File

@ -87,6 +87,10 @@ Node::GetNDevices (void) const
return m_devices.size ();
}
void Node::Dispose()
{
}
// Node stack creation and management routines.
Node* Node::Create()
{

View File

@ -122,6 +122,8 @@ public:
uint32_t AddDevice (NetDevice *device);
NetDevice *GetDevice (uint32_t index) const;
uint32_t GetNDevices (void) const;
virtual void Dispose();
private:
virtual void DoAddDevice (NetDevice *device) const = 0;