Oolite
Loading...
Searching...
No Matches
OOAsyncQueue(OOPrivate) Category Reference

Instance Methods

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

Detailed Description

Definition at line 72 of file OOAsyncQueue.m.

Method Documentation

◆ doDequeAndUnlockWithAcquiredLock

- (id) doDequeAndUnlockWithAcquiredLock

Extends class OOAsyncQueue.

Definition at line 246 of file OOAsyncQueue.m.

247{
248 OOAsyncQueueElement* element = NULL;
249 id result;
250
251 if (_head == NULL) {
252 // Can happen if you enter debugger.
253 return nil;
254 }
255
256 // assert(_head != NULL);
257
258 // Dequeue element.
259 element = _head;
260 _head = _head->next;
261 if (_head == NULL)
262 _tail = NULL;
263 --_elemCount;
264
265 // Unpack payload.
266 result = [element->object autorelease];
267
268 // Recycle element.
269 [self recycleElementWithAcquiredLock:element];
270
271 // Ensure sane status.
272 assert((_head == NULL && _tail == NULL && _elemCount == 0) || (_head != NULL && _tail != NULL && _elemCount != 0));
273
274 // Unlock with appropriate state.
275 [_lock unlockWithCondition:(_head == NULL) ? kConditionNoData : kConditionQueuedData];
276
277 return result;
278}
struct OOAsyncQueueElement OOAsyncQueueElement
return nil
OOAsyncQueueElement * next

References doDequeAndUnlockWithAcquiredLock, OOAsyncQueueElement::next, nil, and OOAsyncQueue::recycleElementWithAcquiredLock:.

Referenced by doDequeAndUnlockWithAcquiredLock.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ doEmptyQueueWithAcquiredLock

- (void) doEmptyQueueWithAcquiredLock

Extends class OOAsyncQueue.

Definition at line 225 of file OOAsyncQueue.m.

226{
227 OOAsyncQueueElement* element = NULL;
228
229 // Loop over queue.
230 while (_head != NULL) {
231 // Dequeue element.
232 element = _head;
233 _head = _head->next;
234 --_elemCount;
235
236 // We don't need the payload any longer.
237 [element->object release];
238
239 // Or the element.
240 [self recycleElementWithAcquiredLock:element];
241 }
242
243 _tail = NULL;
244}

References doEmptyQueueWithAcquiredLock, OOAsyncQueueElement::next, and OOAsyncQueue::recycleElementWithAcquiredLock:.

Referenced by doEmptyQueueWithAcquiredLock.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ recycleElementWithAcquiredLock:

- (void) recycleElementWithAcquiredLock: (OOAsyncQueueElement*) element

Extends class OOAsyncQueue.

Definition at line 280 of file OOAsyncQueue.m.

280 :(OOAsyncQueueElement*)element
281{
282 if (_poolCount < kMaxPoolElements) {
283 // Add to pool for reuse.
284 element->next = _pool;
285 _pool = element;
286 ++_poolCount;
287 } else {
288 // Delete.
289 FreeElement(element);
290 }
291}
OOINLINE void FreeElement(OOAsyncQueueElement *element)
@ kMaxPoolElements

References FreeElement(), kMaxPoolElements, and OOAsyncQueueElement::next.

Here is the call graph for this function:

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