#include <OOAsyncQueue.h>
Definition at line 36 of file OOAsyncQueue.h.
◆ count
◆ dealloc
Definition at line 64 of file OOAsyncQueue.m.
110{
112
113 [_lock lock];
114
116 {
117 OOLogWARN(
@"asyncQueue.nonEmpty",
@"%@ deallocated while non-empty, flushing.",
self);
118 [self doEmptyQueueWithAcquiredLock];
119 }
120
121
122 while (
_pool != NULL)
123 {
126 free(element);
127 }
128
129 [_lock unlockWithCondition:kConditionDead];
130 [_lock release];
131
132 [super dealloc];
133}
#define OOLogWARN(class, format,...)
struct OOAsyncQueueElement * _pool
OOAsyncQueueElement * next
◆ dequeue
Definition at line 64 of file OOAsyncQueue.m.
197{
198 [_lock lockWhenCondition:kConditionQueuedData];
199 return [self doDequeAndUnlockWithAcquiredLock];
200}
◆ description
- (NSString *) description |
|
|
|
|
implementation |
Definition at line 64 of file OOAsyncQueue.m.
137{
138
139 return [NSString stringWithFormat:@"<%@ %p>{%u elements}", [self class], self, _elemCount];
140}
◆ doDequeAndUnlockWithAcquiredLock
- (id) doDequeAndUnlockWithAcquiredLock |
|
|
|
|
implementation |
Provided by category OOAsyncQueue(OOPrivate).
Definition at line 64 of file OOAsyncQueue.m.
275{
277 id result;
278
279 if (_head == NULL)
280 {
281
283 }
284
285
286
287
288 element = _head;
290 if (_head == NULL) _tail = NULL;
291 --_elemCount;
292
293
294 result = [element->object autorelease];
295
296
297 [self recycleElementWithAcquiredLock:element];
298
299
300 assert((_head == NULL && _tail == NULL && _elemCount == 0) || (_head != NULL && _tail != NULL && _elemCount != 0));
301
302
303 [_lock unlockWithCondition:(_head == NULL) ? kConditionNoData : kConditionQueuedData];
304
305 return result;
306}
◆ doEmptyQueueWithAcquiredLock
- (void) doEmptyQueueWithAcquiredLock |
|
|
|
|
implementation |
Provided by category OOAsyncQueue(OOPrivate).
Definition at line 64 of file OOAsyncQueue.m.
252{
254
255
256 while (_head != NULL)
257 {
258
259 element = _head;
261 --_elemCount;
262
263
264 [element->object release];
265
266
267 [self recycleElementWithAcquiredLock:element];
268 }
269
270 _tail = NULL;
271}
◆ empty
Definition at line 64 of file OOAsyncQueue.m.
226{
227 return _head != NULL;
228}
struct OOAsyncQueueElement * _head
◆ emptyQueue
Definition at line 64 of file OOAsyncQueue.m.
238{
239 [_lock lock];
240 [self doEmptyQueueWithAcquiredLock];
241
243 [_lock unlockWithCondition:kConditionNoData];
244}
struct OOAsyncQueueElement * _tail
◆ enqueue:
- (BOOL) enqueue: |
|
(id) | object |
|
Definition at line 64 of file OOAsyncQueue.m.
143 :(id)object
144{
146 BOOL success = NO;
147
149
150 [_lock lock];
151
152
154 {
158 }
159 else
160 {
162 if (element == NULL)
goto FAIL;
163 }
164
165
166 element->
object = [object retain];
167 element->
next = NULL;
168
169
171 {
172
174 element->
next = NULL;
177 }
178 else
179 {
180 assert(
_tail != NULL);
183
187 }
188 success = YES;
189
191 [_lock unlockWithCondition:kConditionQueuedData];
192 return success;
193}
OOINLINE OOAsyncQueueElement * AllocElement(void)
◆ init
Definition at line 64 of file OOAsyncQueue.m.
92{
93 self = [super init];
95 {
96 _lock = [[NSConditionLock alloc] initWithCondition:kConditionNoData];
97 [_lock setName:@"OOAsyncQueue lock"];
99 {
100 [self release];
102 }
103 }
104
105 return self;
106}
◆ recycleElementWithAcquiredLock:
Provided by category OOAsyncQueue(OOPrivate).
Definition at line 64 of file OOAsyncQueue.m.
310{
312 {
313
314 element->
next = _pool;
315 _pool = element;
316 ++_poolCount;
317 }
318 else
319 {
320
322 }
323}
OOINLINE void FreeElement(OOAsyncQueueElement *element)
◆ tryDequeue
Definition at line 64 of file OOAsyncQueue.m.
204{
205#if OO_BUGGY_PTHREADS
206
207
208
209
210
211 [_lock lock];
213 {
214 [_lock unlock];
215 return NO;
216 }
217#else
218
220#endif
221 return [self doDequeAndUnlockWithAcquiredLock];
222}
◆ _elemCount
◆ _head
◆ _lock
- (NSConditionLock*) _lock |
|
private |
◆ _pool
◆ _poolCount
◆ _tail
The documentation for this class was generated from the following files: