Oolite 1.91.0.7645-241119-222d325
Loading...
Searching...
No Matches
OOAsyncQueue(OOPrivate) Category Reference

Instance Methods

(void) - doEmptyQueueWithAcquiredLock
 
(id) - doDequeAndUnlockWithAcquiredLock
 
(void) - recycleElementWithAcquiredLock:
 

Detailed Description

Definition at line 80 of file OOAsyncQueue.m.

Method Documentation

◆ doDequeAndUnlockWithAcquiredLock

- (id) doDequeAndUnlockWithAcquiredLock

Extends class OOAsyncQueue.

Definition at line 64 of file OOAsyncQueue.m.

275{
276 OOAsyncQueueElement *element = NULL;
277 id result;
278
279 if (_head == NULL)
280 {
281 // Can happen if you enter debugger.
282 return nil;
283 }
284
285// assert(_head != NULL);
286
287 // Dequeue element.
288 element = _head;
289 _head = _head->next;
290 if (_head == NULL) _tail = NULL;
291 --_elemCount;
292
293 // Unpack payload.
294 result = [element->object autorelease];
295
296 // Recycle element.
297 [self recycleElementWithAcquiredLock:element];
298
299 // Ensure sane status.
300 assert((_head == NULL && _tail == NULL && _elemCount == 0) || (_head != NULL && _tail != NULL && _elemCount != 0));
301
302 // Unlock with appropriate state.
303 [_lock unlockWithCondition:(_head == NULL) ? kConditionNoData : kConditionQueuedData];
304
305 return result;
306}
return nil
OOAsyncQueueElement * next

◆ doEmptyQueueWithAcquiredLock

- (void) doEmptyQueueWithAcquiredLock

Extends class OOAsyncQueue.

Definition at line 64 of file OOAsyncQueue.m.

252{
253 OOAsyncQueueElement *element = NULL;
254
255 // Loop over queue.
256 while (_head != NULL)
257 {
258 // Dequeue element.
259 element = _head;
260 _head = _head->next;
261 --_elemCount;
262
263 // We don't need the payload any longer.
264 [element->object release];
265
266 // Or the element.
267 [self recycleElementWithAcquiredLock:element];
268 }
269
270 _tail = NULL;
271}

◆ recycleElementWithAcquiredLock:

- (void) recycleElementWithAcquiredLock: (OOAsyncQueueElement *) element

Extends class OOAsyncQueue.

Definition at line 64 of file OOAsyncQueue.m.

309 :(OOAsyncQueueElement *)element
310{
311 if (_poolCount < kMaxPoolElements)
312 {
313 // Add to pool for reuse.
314 element->next = _pool;
315 _pool = element;
316 ++_poolCount;
317 }
318 else
319 {
320 // Delete.
321 FreeElement(element);
322 }
323}
@ kMaxPoolElements
OOINLINE void FreeElement(OOAsyncQueueElement *element)

The documentation for this category was generated from the following file: