Oolite
Loading...
Searching...
No Matches
OOAsyncWorkManagerInternal Class Reference
Inheritance diagram for OOAsyncWorkManagerInternal:
Collaboration diagram for OOAsyncWorkManagerInternal:

Instance Methods

(void) - queueResult:
(void) - noteTaskQueued:
(id) - init [implementation]
(void) - completePendingTasks [implementation]
(void) - waitForTaskToComplete: [implementation]
Instance Methods inherited from OOAsyncWorkManager
(BOOL) - addTask:priority:
(void) - dealloc [implementation]
(oneway void) - release [implementation]
(id) - retain [implementation]
(NSUInteger) - retainCount [implementation]

Private Attributes

OOAsyncQueue * _readyQueue
NSMutableSet * _pendingCompletableOperations
NSLock * _pendingOpsLock

Additional Inherited Members

Class Methods inherited from OOAsyncWorkManager
(OOAsyncWorkManager *) + sharedAsyncWorkManager
(id) + allocWithZone: [implementation]

Detailed Description

Definition at line 53 of file OOAsyncWorkManager.m.

Method Documentation

◆ completePendingTasks

- (void) completePendingTasks
implementation

Reimplemented from OOAsyncWorkManager.

Definition at line 220 of file OOAsyncWorkManager.m.

221{
222 id next = nil;
223
224 [_pendingOpsLock lock];
225 for (;;) {
226 next = [_readyQueue tryDequeue];
227 if (next == nil)
228 break;
229
230 [_pendingCompletableOperations removeObject:next];
231 [next completeAsyncTask];
232 }
233 [_pendingOpsLock unlock];
234}
return nil

References completePendingTasks, nil, and OOAsyncQueue::tryDequeue.

Referenced by completePendingTasks.

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

◆ init

- (id) init
implementation

Reimplemented in OOOperationQueueAsyncWorkManager.

Definition at line 198 of file OOAsyncWorkManager.m.

199{
200 if ((self = [super init])) {
201 _readyQueue = [[OOAsyncQueue alloc] init];
202
203 if (_readyQueue == nil) {
204 [self release];
205 return nil;
206 }
207
208 _pendingCompletableOperations = [[NSMutableSet alloc] init];
209 _pendingOpsLock = [[NSLock alloc] init];
210
212 [self release];
213 return nil;
214 }
215 }
216
217 return self;
218}
NSMutableSet * _pendingCompletableOperations

References _pendingCompletableOperations, _pendingOpsLock, _readyQueue, init, nil, and OOAsyncWorkManager::release.

Referenced by init.

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

◆ noteTaskQueued:

- (void) noteTaskQueued: (id<OOAsyncWorkTask>) task

Definition at line 275 of file OOAsyncWorkManager.m.

275 :(id<OOAsyncWorkTask>)task
276{
277 [_pendingOpsLock lock];
278 [_pendingCompletableOperations addObject:task];
279 [_pendingOpsLock unlock];
280}

Referenced by OOOperationQueueAsyncWorkManager::addTask:priority:.

Here is the caller graph for this function:

◆ queueResult:

- (void) queueResult: (id<OOAsyncWorkTask>) task

Definition at line 268 of file OOAsyncWorkManager.m.

268 :(id<OOAsyncWorkTask>)task
269{
270 if ([task respondsToSelector:@selector(completeAsyncTask)]) {
271 [_readyQueue enqueue:task];
272 }
273}

References OOAsyncQueue::enqueue:.

Referenced by OOOperationQueueAsyncWorkManager::dispatchTask:.

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

◆ waitForTaskToComplete:

- (void) waitForTaskToComplete: (id<OOAsyncWorkTask>) task
implementation

Reimplemented from OOAsyncWorkManager.

Definition at line 236 of file OOAsyncWorkManager.m.

236 :(id<OOAsyncWorkTask>)task
237{
238 if (task == nil)
239 return;
240
241#if OO_DEBUG
242 NSParameterAssert([(id)task respondsToSelector:@selector(completeAsyncTask)]);
243 NSAssert1(![NSThread respondsToSelector:@selector(isMainThread)] || [[NSThread self] isMainThread], @"%s can only be called from the main thread.", __PRETTY_FUNCTION__);
244#endif
245
246 [_pendingOpsLock lock];
247 BOOL exists = [_pendingCompletableOperations containsObject:task];
248 if (exists)
249 [_pendingCompletableOperations removeObject:task];
250 [_pendingOpsLock unlock];
251
252 if (!exists)
253 return;
254
255 id next = nil;
256 do {
257 // Dequeue a task and complete it.
258 next = [_readyQueue dequeue];
259 [_pendingOpsLock lock];
260 [_pendingCompletableOperations removeObject:next];
261 [_pendingOpsLock unlock];
262
263 [next completeAsyncTask];
264
265 } while (next != task); // We don't control order, so keep looking until we get the one we care about.
266}

References OOAsyncQueue::dequeue, and nil.

Here is the call graph for this function:

Member Data Documentation

◆ _pendingCompletableOperations

- (NSMutableSet*) _pendingCompletableOperations
private

Definition at line 57 of file OOAsyncWorkManager.m.

Referenced by init.

◆ _pendingOpsLock

- (NSLock*) _pendingOpsLock
private

Definition at line 58 of file OOAsyncWorkManager.m.

Referenced by init.

◆ _readyQueue

- (OOAsyncQueue*) _readyQueue
private

Definition at line 55 of file OOAsyncWorkManager.m.

Referenced by init.


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