equal
deleted
inserted
replaced
48 * Increment the reference count. This method should not be called |
48 * Increment the reference count. This method should not be called |
49 * by user code. RefCountBase instances are expected to be used in |
49 * by user code. RefCountBase instances are expected to be used in |
50 * conjunction with the Ptr template which would make calling Ref |
50 * conjunction with the Ptr template which would make calling Ref |
51 * unecessary and dangerous. |
51 * unecessary and dangerous. |
52 */ |
52 */ |
53 inline void Ref () const; |
53 inline void Ref (void) const; |
54 /** |
54 /** |
55 * Decrement the reference count. This method should not be called |
55 * Decrement the reference count. This method should not be called |
56 * by user code. RefCountBase instances are expected to be used in |
56 * by user code. RefCountBase instances are expected to be used in |
57 * conjunction with the Ptr template which would make calling Ref |
57 * conjunction with the Ptr template which would make calling Ref |
58 * unecessary and dangerous. |
58 * unecessary and dangerous. |
59 */ |
59 */ |
60 inline void Unref () const; |
60 inline void Unref (void) const; |
|
61 |
61 private: |
62 private: |
62 // Note we make this mutable so that the const methods can still |
63 // Note we make this mutable so that the const methods can still |
63 // change it. |
64 // change it. |
64 mutable uint32_t m_count; // Reference count |
65 mutable uint32_t m_count; // Reference count |
65 }; |
66 }; |
68 |
69 |
69 namespace ns3 { |
70 namespace ns3 { |
70 |
71 |
71 // Implementation of the in-line methods |
72 // Implementation of the in-line methods |
72 void |
73 void |
73 RefCountBase::Ref () const |
74 RefCountBase::Ref (void) const |
74 { |
75 { |
75 m_count++; |
76 m_count++; |
76 } |
77 } |
77 |
78 |
78 void |
79 void |
79 RefCountBase::Unref () const |
80 RefCountBase::Unref (void) const |
80 { |
81 { |
81 if (--m_count == 0) |
82 m_count--; |
|
83 if (m_count == 0) |
82 { // All references removed, ok to delete |
84 { // All references removed, ok to delete |
83 delete this; |
85 delete this; |
84 } |
86 } |
85 } |
87 } |
86 |
88 |