48
48
* @endcode
49
49
*
50
50
*
51
- * It is similar to the std::shared_ptr class introduced in C++11,
52
- * however this is not a compatible implementation (no weak pointer, no make_shared, no custom deleters, etc .)
51
+ * It is similar to the std::shared_ptr class introduced in C++11;
52
+ * however, this is not a compatible implementation (no weak pointer, no make_shared, no custom deleters and so on .)
53
53
*
54
54
* Usage: SharedPtr<Class> ptr(new Class())
55
55
*
56
- * When ptr is passed around by value the copy constructor and
56
+ * When ptr is passed around by value, the copy constructor and
57
57
* destructor manages the reference count of the raw pointer.
58
58
* If the counter reaches zero, delete is called on the raw pointer.
59
59
*
60
- * To avoid loops, "weak" references should be used by calling the original
60
+ * To avoid loops, use "weak" references by calling the original
61
61
* pointer directly through ptr.get().
62
62
*/
63
63
@@ -78,7 +78,7 @@ class SharedPtr {
78
78
*/
79
79
SharedPtr (T *ptr): _ptr(ptr), _counter(NULL )
80
80
{
81
- // allocate counter on the heap so it can be shared
81
+ // Allocate counter on the heap, so it can be shared
82
82
if (_ptr != NULL ) {
83
83
_counter = new uint32_t ;
84
84
*_counter = 1 ;
@@ -87,7 +87,7 @@ class SharedPtr {
87
87
88
88
/* *
89
89
* @brief Destructor.
90
- * @details Decrement reference counter and delete object if no longer pointed to.
90
+ * @details Decrement reference counter, and delete object if no longer pointed to.
91
91
*/
92
92
~SharedPtr ()
93
93
{
@@ -102,7 +102,7 @@ class SharedPtr {
102
102
*/
103
103
SharedPtr (const SharedPtr &source): _ptr(source._ptr), _counter(source._counter)
104
104
{
105
- // increment reference counter
105
+ // Increment reference counter
106
106
if (_ptr != NULL ) {
107
107
core_util_atomic_incr_u32 (_counter, 1 );
108
108
}
@@ -117,14 +117,14 @@ class SharedPtr {
117
117
SharedPtr operator =(const SharedPtr &source)
118
118
{
119
119
if (this != &source) {
120
- // clean up by decrementing counter
120
+ // Clean up by decrementing counter
121
121
decrement_counter ();
122
122
123
- // assign new values
123
+ // Assign new values
124
124
_ptr = source.get ();
125
125
_counter = source.get_counter ();
126
126
127
- // increment new counter
127
+ // Increment new counter
128
128
if (_ptr != NULL ) {
129
129
core_util_atomic_incr_u32 (_counter, 1 );
130
130
}
@@ -139,11 +139,11 @@ class SharedPtr {
139
139
*/
140
140
void reset (T *ptr)
141
141
{
142
- // clean up by decrementing counter
142
+ // Clean up by decrementing counter
143
143
decrement_counter ();
144
144
145
145
if (ptr != NULL ) {
146
- // allocate counter on the heap so it can be shared
146
+ // Allocate counter on the heap, so it can be shared
147
147
_counter = new uint32_t ;
148
148
*_counter = 1 ;
149
149
}
@@ -237,10 +237,10 @@ class SharedPtr {
237
237
}
238
238
239
239
private:
240
- // pointer to shared object
240
+ // Pointer to shared object
241
241
T *_ptr;
242
242
243
- // pointer to shared reference counter
243
+ // Pointer to shared reference counter
244
244
uint32_t *_counter;
245
245
};
246
246
0 commit comments