~skinny.moey/drizzle/innodb-replication

« back to all changes in this revision

Viewing changes to plugin/pbms/src/cslib/CSObject.cc

  • Committer: Brian Aker
  • Date: 2010-11-08 22:35:57 UTC
  • mfrom: (1802.1.114 trunk)
  • Revision ID: brian@tangent.org-20101108223557-w3xzwp9hjjtjhtc1
MergeĀ inĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
 *
15
15
 * You should have received a copy of the GNU General Public License
16
16
 * along with this program; if not, write to the Free Software
17
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
17
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
18
 *
19
19
 * Original author: Paul McCullagh (H&G2JCtL)
20
20
 * Continued development: Barry Leslie
44
44
 * BASIC OBJECTS
45
45
 */
46
46
 
 
47
#ifdef DEBUG
 
48
void CSObject::retain(const char *func, const char *file, uint32_t line)
 
49
{
 
50
        CSException::throwAssertion(func, file, line, "Non-referenced object cannot be referenced");
 
51
}
 
52
#else
47
53
void CSObject::retain()
48
54
{
49
55
        CSException::throwAssertion(CS_CONTEXT, "Non-referenced object cannot be referenced");
50
56
}
 
57
#endif
51
58
 
 
59
#ifdef DEBUG
 
60
void CSObject::release(const char *, const char *, uint32_t )
 
61
#else
52
62
void CSObject::release()
53
 
{
54
 
        delete this;
55
 
}
56
 
 
57
 
#ifdef DEBUG
58
 
/*
59
 
void CSObject::retain(const char *func, const char *file, uint32_t line)
60
 
{
61
 
        CSException::throwAssertion(CS_CONTEXT, "Non-referenced object cannot be referenced");
62
 
}
63
 
 
64
 
void CSObject::release(const char *func, const char *file, uint32_t line)
65
 
{
66
 
        delete this;
67
 
}
68
 
*/
69
63
#endif
 
64
{
 
65
        delete this;
 
66
}
70
67
 
71
68
CSObject *CSObject::getKey() { CSException::throwCoreError(CS_CONTEXT, CS_ERR_IMPL_MISSING, __FUNC__); return NULL; }
72
69
 
85
82
void CSObject::setNextLink(CSObject *) { CSException::throwCoreError(CS_CONTEXT, CS_ERR_IMPL_MISSING, __FUNC__); }
86
83
 
87
84
void CSObject::setPrevLink(CSObject *) { CSException::throwCoreError(CS_CONTEXT, CS_ERR_IMPL_MISSING, __FUNC__); }
 
85
 
 
86
/*
 
87
 * ---------------------------------------------------------------
 
88
 * STATIC OBJECTS
 
89
 */
 
90
 
 
91
#ifdef DEBUG
 
92
void CSStaticObject::retain(const char *, const char *, uint32_t )
 
93
#else
 
94
void CSStaticObject::retain()
 
95
#endif
 
96
{
 
97
}
 
98
 
 
99
#ifdef DEBUG
 
100
void CSStaticObject::release(const char *, const char *, uint32_t )
 
101
#else
 
102
void CSStaticObject::release()
 
103
#endif
 
104
{
 
105
        finalize();
 
106
}
 
107
 
88
108
/*
89
109
 * ---------------------------------------------------------------
90
110
 * REFERENCE OBJECTS
91
111
 */
 
112
 
92
113
CSRefObject::CSRefObject():
93
114
CSObject(),
94
115
iRefCount(1)
104
125
        ASSERT(iRefCount == 0);
105
126
}
106
127
 
 
128
#ifdef DEBUG
 
129
void CSRefObject::retain(const char *func, const char *file, uint32_t line)
 
130
#else
107
131
void CSRefObject::retain()
 
132
#endif
108
133
{
109
134
        if (!iRefCount)
110
135
                CSException::throwAssertion(CS_CONTEXT, "Freed object being retained.");
111
136
                
112
137
        iRefCount++;
113
138
#ifdef DEBUG
114
 
        cs_mm_track_memory(NULL, NULL, 0, this, true, iRefCount, iTrackMe);
 
139
        cs_mm_track_memory(func, file, line, this, true, iRefCount, iTrackMe);
115
140
#endif
116
141
}
117
142
 
 
143
#ifdef DEBUG
 
144
void CSRefObject::release(const char *func, const char *file, uint32_t line)
 
145
#else
118
146
void CSRefObject::release()
119
 
{
120
 
        bool terminate;
121
 
 
122
 
#ifdef DEBUG
123
 
        cs_mm_track_memory(NULL, NULL, 0, this, false, iRefCount, iTrackMe);
124
147
#endif
125
 
        iRefCount--;
126
 
        if (!iRefCount)
127
 
                terminate = true;
128
 
        else
129
 
                terminate = false;
130
 
 
131
 
        if (terminate)
132
 
                delete this;
133
 
}
 
148
{
 
149
        bool terminate;
134
150
 
135
151
#ifdef DEBUG
136
 
/*
137
 
void CSRefObject::retain(const char *func, const char *file, uint32_t line)
138
 
{
139
 
        iRefCount++;
140
 
        cs_mm_print_track(func, file, line, this, true, iRefCount);
141
 
}
142
 
 
143
 
void CSRefObject::release(const char *func, const char *file, uint32_t line)
144
 
{
145
 
        bool terminate;
146
 
 
147
152
        cs_mm_track_memory(func, file, line, this, false, iRefCount, iTrackMe);
 
153
#endif
148
154
        iRefCount--;
149
155
        if (!iRefCount)
150
156
                terminate = true;
154
160
        if (terminate)
155
161
                delete this;
156
162
}
157
 
*/
 
163
 
 
164
#ifdef DEBUG
 
165
void CSRefObject::startTracking()
 
166
{
 
167
        iTrackMe = 1;
 
168
        cs_mm_track_memory(NULL, NULL, 0, this, true, iRefCount, iTrackMe);
 
169
}
158
170
#endif
159
171
 
160
172
/*
178
190
        ASSERT(iRefCount == 0);
179
191
}
180
192
 
 
193
#ifdef DEBUG
 
194
void CSSharedRefObject::retain(const char *func, const char *file, uint32_t line)
 
195
#else
181
196
void CSSharedRefObject::retain()
 
197
#endif
182
198
{
183
199
        lock();
184
200
        iRefCount++;
185
201
#ifdef DEBUG
186
 
        cs_mm_track_memory(NULL, NULL, 0, this, true, iRefCount, iTrackMe);
 
202
        cs_mm_track_memory(func, file, line, this, true, iRefCount, iTrackMe);
187
203
#endif
188
204
        unlock();
189
205
}
190
206
 
 
207
#ifdef DEBUG
 
208
void CSSharedRefObject::release(const char *func, const char *file, uint32_t line)
 
209
#else
191
210
void CSSharedRefObject::release()
 
211
#endif
192
212
{
193
213
        bool terminate;
194
214
 
195
215
        lock();
196
216
#ifdef DEBUG
197
 
        cs_mm_track_memory(NULL, NULL, 0, this, false, iRefCount, iTrackMe);
 
217
        cs_mm_track_memory(func, file, line, this, false, iRefCount, iTrackMe);
198
218
#endif
199
219
        iRefCount--;
200
220
        if (!iRefCount)