~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-10-02 14:17:48 UTC
  • mfrom: (1.1.1 upstream)
  • mto: (2.1.17 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20101002141748-m6vbfbfjhrw1153e
Tags: 2010.09.1802-1
* New upstream release.
* Removed pid-file argument hack.
* Updated GPL-2 address to be new address.
* Directly copy in drizzledump.1 since debian doesn't have sphinx 1.0 yet.
* Link to jquery from libjs-jquery. Add it as a depend.
* Add drizzled.8 symlink to the install files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (c) 2008 PrimeBase Technologies GmbH, Germany
 
2
 *
 
3
 * PrimeBase Media Stream for MySQL
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or modify
 
6
 * it under the terms of the GNU General Public License as published by
 
7
 * the Free Software Foundation; either version 2 of the License, or
 
8
 * (at your option) any later version.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
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
 
18
 *
 
19
 * Original author: Paul McCullagh (H&G2JCtL)
 
20
 * Continued development: Barry Leslie
 
21
 *
 
22
 * 2007-05-20
 
23
 *
 
24
 * A basic syncronized object.
 
25
 *
 
26
 */
 
27
 
 
28
#include "CSConfig.h"
 
29
 
 
30
#include <assert.h>
 
31
 
 
32
#include "CSGlobal.h"
 
33
#include "CSDefs.h"
 
34
#include "CSObject.h"
 
35
#include "CSMemory.h"
 
36
 
 
37
#ifdef DEBUG
 
38
#undef retain
 
39
#undef release
 
40
#endif
 
41
 
 
42
/*
 
43
 * ---------------------------------------------------------------
 
44
 * BASIC OBJECTS
 
45
 */
 
46
 
 
47
void CSObject::retain()
 
48
{
 
49
        CSException::throwAssertion(CS_CONTEXT, "Non-referenced object cannot be referenced");
 
50
}
 
51
 
 
52
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
#endif
 
70
 
 
71
CSObject *CSObject::getKey() { CSException::throwCoreError(CS_CONTEXT, CS_ERR_IMPL_MISSING, __FUNC__); return NULL; }
 
72
 
 
73
int CSObject::compareKey(CSObject *)  { CSException::throwCoreError(CS_CONTEXT, CS_ERR_IMPL_MISSING, __FUNC__); return 0; }
 
74
 
 
75
uint32_t CSObject::hashKey()  { CSException::throwCoreError(CS_CONTEXT, CS_ERR_IMPL_MISSING, __FUNC__); return 0; }
 
76
 
 
77
CSObject *CSObject::getHashLink() { CSException::throwCoreError(CS_CONTEXT, CS_ERR_IMPL_MISSING, __FUNC__); return NULL; }
 
78
 
 
79
void CSObject::setHashLink(CSObject *) { CSException::throwCoreError(CS_CONTEXT, CS_ERR_IMPL_MISSING, __FUNC__); }
 
80
 
 
81
CSObject *CSObject::getNextLink() { CSException::throwCoreError(CS_CONTEXT, CS_ERR_IMPL_MISSING, __FUNC__); return NULL; }
 
82
 
 
83
CSObject *CSObject::getPrevLink() { CSException::throwCoreError(CS_CONTEXT, CS_ERR_IMPL_MISSING, __FUNC__); return NULL; }
 
84
 
 
85
void CSObject::setNextLink(CSObject *) { CSException::throwCoreError(CS_CONTEXT, CS_ERR_IMPL_MISSING, __FUNC__); }
 
86
 
 
87
void CSObject::setPrevLink(CSObject *) { CSException::throwCoreError(CS_CONTEXT, CS_ERR_IMPL_MISSING, __FUNC__); }
 
88
/*
 
89
 * ---------------------------------------------------------------
 
90
 * REFERENCE OBJECTS
 
91
 */
 
92
CSRefObject::CSRefObject():
 
93
CSObject(),
 
94
iRefCount(1)
 
95
{
 
96
#ifdef DEBUG
 
97
        iTrackMe = 0;
 
98
        cs_mm_track_memory(NULL, NULL, 0, this, true, iRefCount, iTrackMe);
 
99
#endif
 
100
}
 
101
 
 
102
CSRefObject::~CSRefObject()
 
103
{
 
104
        ASSERT(iRefCount == 0);
 
105
}
 
106
 
 
107
void CSRefObject::retain()
 
108
{
 
109
        if (!iRefCount)
 
110
                CSException::throwAssertion(CS_CONTEXT, "Freed object being retained.");
 
111
                
 
112
        iRefCount++;
 
113
#ifdef DEBUG
 
114
        cs_mm_track_memory(NULL, NULL, 0, this, true, iRefCount, iTrackMe);
 
115
#endif
 
116
}
 
117
 
 
118
void CSRefObject::release()
 
119
{
 
120
        bool terminate;
 
121
 
 
122
#ifdef DEBUG
 
123
        cs_mm_track_memory(NULL, NULL, 0, this, false, iRefCount, iTrackMe);
 
124
#endif
 
125
        iRefCount--;
 
126
        if (!iRefCount)
 
127
                terminate = true;
 
128
        else
 
129
                terminate = false;
 
130
 
 
131
        if (terminate)
 
132
                delete this;
 
133
}
 
134
 
 
135
#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
        cs_mm_track_memory(func, file, line, this, false, iRefCount, iTrackMe);
 
148
        iRefCount--;
 
149
        if (!iRefCount)
 
150
                terminate = true;
 
151
        else
 
152
                terminate = false;
 
153
 
 
154
        if (terminate)
 
155
                delete this;
 
156
}
 
157
*/
 
158
#endif
 
159
 
 
160
/*
 
161
 * ---------------------------------------------------------------
 
162
 * SHARED REFERENCE OBJECTS
 
163
 */
 
164
 
 
165
CSSharedRefObject::CSSharedRefObject():
 
166
CSObject(),
 
167
CSSync(),
 
168
iRefCount(1)
 
169
{
 
170
#ifdef DEBUG
 
171
        iTrackMe = 0;
 
172
        cs_mm_track_memory(NULL, NULL, 0, this, true, iRefCount, iTrackMe);
 
173
#endif
 
174
}
 
175
 
 
176
CSSharedRefObject::~CSSharedRefObject()
 
177
{
 
178
        ASSERT(iRefCount == 0);
 
179
}
 
180
 
 
181
void CSSharedRefObject::retain()
 
182
{
 
183
        lock();
 
184
        iRefCount++;
 
185
#ifdef DEBUG
 
186
        cs_mm_track_memory(NULL, NULL, 0, this, true, iRefCount, iTrackMe);
 
187
#endif
 
188
        unlock();
 
189
}
 
190
 
 
191
void CSSharedRefObject::release()
 
192
{
 
193
        bool terminate;
 
194
 
 
195
        lock();
 
196
#ifdef DEBUG
 
197
        cs_mm_track_memory(NULL, NULL, 0, this, false, iRefCount, iTrackMe);
 
198
#endif
 
199
        iRefCount--;
 
200
        if (!iRefCount)
 
201
                terminate = true;
 
202
        else
 
203
                terminate = false;
 
204
        unlock();
 
205
 
 
206
        if (terminate)
 
207
                delete this;
 
208
}
 
209
 
 
210
#ifdef DEBUG
 
211
void CSSharedRefObject::startTracking()
 
212
{
 
213
        iTrackMe = 1;
 
214
        cs_mm_track_memory(NULL, NULL, 0, this, true, iRefCount, iTrackMe);
 
215
}
 
216
#endif
 
217
 
 
218
#ifdef DEBUG
 
219
/*
 
220
void CSSharedRefObject::retain(const char *func, const char *file, uint32_t line)
 
221
{
 
222
        lock();
 
223
        iRefCount++;
 
224
        cs_mm_print_track(func, file, line, this, true, iRefCount);
 
225
        unlock();
 
226
}
 
227
 
 
228
void CSSharedRefObject::release(const char *func, const char *file, uint32_t line)
 
229
{
 
230
        bool terminate;
 
231
 
 
232
        lock();
 
233
        cs_mm_track_memory(func, file, line, this, false, iRefCount, iTrackMe);
 
234
        iRefCount--;
 
235
        if (!iRefCount)
 
236
                terminate = true;
 
237
        else
 
238
                terminate = false;
 
239
        unlock();
 
240
 
 
241
        if (terminate)
 
242
                delete this;
 
243
}
 
244
*/
 
245
#endif
 
246
 
 
247